2

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 (e.g. 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?

gcswoosh
  • 1,279
  • 1
  • 15
  • 31
  • What command did you use to add and commit? – Gogol May 22 '15 at 13:59
  • of course you can ignore `vendor` folder, most developers do so, because a project can be updated permanently, but it doesnt dependent to the code, so it is good for everyone to get dependencies by `composer` – iamawebgeek May 22 '15 at 14:16

2 Answers2

6

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 (e.g. 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.

Bfcm
  • 2,686
  • 2
  • 27
  • 34
  • It does not answer the question. – Gogol May 22 '15 at 13:57
  • Why not? 1. It's not necessary to push `vendor` to git. 2. If composer is used - simply use it again for getting dependencies. 3. Composer is a pretty good approach to handle project with git. – Bfcm May 22 '15 at 14:01
  • @noc2spamツ you are wrong, this is an appropriate answer. upvoted, wanted to write the same :) – iamawebgeek May 22 '15 at 14:13
  • @zazu, thank you zazu :) I hope my answer would help gcswoosh – Bfcm May 22 '15 at 14:15
  • @zazu, op wanted to know why his vendor directory did not get pushed. That was the primary question. If op thinks it is a good answer, then he probably should remove the `git` tag and rephrase the question. Probably, `http://stackoverflow.com/questions/8006393/force-add-despite-the-gitignore-file` could solve the actual problem. This answer be like.. "why does an orange taste sour?" - "Don't try orange, try apple instead" ;) – Gogol May 22 '15 at 19:15
0

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.

Kerem
  • 11,377
  • 5
  • 59
  • 58
Bill Cheng
  • 732
  • 1
  • 8
  • 15