Search code examples
githubzend-framework2composer-phpdependency-managementgit-submodules

How to manage ZF2 modules the right way


I am new to ZF2. I have decided to download ZendSkeletonApplication to ease start of development. I will be developing my own modules for my application. I will also be using various vendor modules.

So I did git clone git://github.com/zendframework/ZendSkeletonApplication.git

Then I did php composer.phar self-update and php composer.phar update I am off to a good start, yes?

Question:

I am using git. I have noticed that despite me using composer.phar, when I've added some dependencies using composer, I still managed to somehow acquire git submodules. And when I push those to GitHub, only the pointers to those submodules are being pushed, and not the files. Because I am making changes in the submodules to make them custom to my application, I kind of need to manage both composer and git submodules to ensure my changes are pushed to GitHub. Do I just go on doing this, or is there a better way?


Solution

  • You should add the directory named vendor into the .gitignore file and not commit anything inside to your repository. Do avoid the git submodules - Composer will take care of all dependencies.

    What you should commit however is the composer.json and the created composer.lock file. If you check out your repository later in a different location, you have to run composer install to completely recreate the installed dependencies. They are exactly specified in that composer.lock file.