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:
- assume the root dir is '/var/www/html',
- the vendor dir is moved to '/var/www/html/frameworks/yii2',
- 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:
- 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.
- 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!