Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 2943

[Wiki] Moving the vendor directory for multiple projects

$
0
0

This How-To is useful if you are planning to move the Yii vendor directory outside the default location.

Or if there is a condition to develop another application under the same Yii2 framework, we could use the same vendor. It could save some space in the shared hosting.

Here we go:

  1. assume the root dir is '/var/www/html',
  2. the vendor dir is moved to '/var/www/html/frameworks/yii2',
  3. the application is located in '/var/www/html/myapp' without vendor directory as it's been moved (point 2) & should be accessible through http://hostname/myapp/web/.

To make the myapp to work, modify these files:

  1. the /web/index.php and yii (right under the project directory -- for Yii command from CLI). change the two lines of required file path (autoload.php & yii.php) to the correct vendor location.
  2. the /config/web.php. add vendorPath to the config with your vendor directory.
$config = [
    // if your framework vendor directory is moved to another place 
    // which is not standard, then set the vendorPath attribute to 
    // the new vendor directory.
    'vendorPath' => '../../frameworks/yii2',
    'components' => [...]
    // ... other configs
]

Done!


Viewing all articles
Browse latest Browse all 2943

Trending Articles