working with Git and Composer

Hi,

I’ve gotten the advanced Yii2 application running and committed it to my own git repository using the default .gitignore file.

But once the github repo is set up, I’m not sure how other developers are supposed to proceeed.

Is each developer supposed to run composer on their own server, then git clone the repo into that same directory? (then run init, then migrate?)

Or git clone first, then run composer on top of it? (won’t that replace files from the repo)?

Would love some guidance here.

-Charlie

How it’s possible? without your composer.json you can not run composer.

Yes,this is.

composer will update dependency in vendor directory and vendor directory is ignored by .gitignore

Hi Charlie,

I work in a team of 6 devs on a git project and we use the following steps which works well for us:

  1. Clone your new project repo on your local sever

  2. inside the your newly cloned local repo run the composer install.

  3. add a .gitignore to stop vendor/ getting committed.

  4. commit everything (including composer files)

When other devs checkout the repo they just have to run composer install inside their new local copy and all their dependencies will get downloaded.

I tend to download composer into each project I am working on instead of running composer globally, that way my composer.phar file is inside the repo too, but each to their own. I think it’s important to keep the composer.json file in the repo so that you can version control your app dependencies.

Cheers

Ash

Thanks guys, this is really helpful. Looking forward to working with Yii2.