简体   繁体   中英

Clone Yii project from git

We are developing a Yii web app and after setting up it in a local laptop we pushed the project into a git repository (without the vendor directory). Now I'd like to pull it in another local machine, but when I try to do that of course the vendor dir is not present and I get some error (eg blank page when accessing the index.php, error when running the requirement.php...).

Should I also push the vendor directory or is it better to download the yii2 framework for each local machine? In the second case, how should I do that, since we already used the composer to create the project previously and we don't want to call it again? Or is there a better approach to handle Yii project with git?

It's pretty simple if you use composer . Composer is a package manager that manages projects dependencies and required libraries.

So there is no need to upload all third party extensions ( vendor folder) to git. Composer will install dependencies (eg libraries) for an application.

Use the official composer documentation .

With command php composer.phar install composer will fetch the packages from composer.json and if you've registered a callback for yiisoft/yii-install it will not only download the code, but also invoke yiic and create a standard web application skeleton at the given location.

How to use composer with Yii you can find here .

Use composer install to install the dependencies for the vendor files.

If you are trying to git clone from github the yii project you are working on. The composer.json has to be modified inorder to update the permissions of

chmod 777 runtime
chmod 777 web/asset
chmod 755 yii

before composer install.

The composer.json only changes the permission on postCreateProject. You have to modify it to post-install-cmd or simply add it into your composer.json. The modified composer.json can be found here:

https://github.com/aznchat100/basic/blob/master/composer.json

See also: https://adamcod.es/2013/03/07/composer-install-vs-composer-update.html to get a better understanding of compser install and composer update difference.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM