Git repository inside composer vendors

Feb 8, 2014

PHP Composer Git PhpStorm

After creating my first laravel package last week, I discovered a tip I wanted to share with you.

If you have write access to a composer package repository, you have the possibility to continue its development while it is installed as requirement in another project. Let's see how we can accomplish this.

Let's do it!

First, you have to make sure the package is not installed yet. If it is, remove it from the composer.json file and run composer update to uninstall it.

Then, add it to composer.json and run composer update using the following option.

$ composer update --prefer-source

The composer option --prefer-source is cloning the package's git repository inside the vendor directory. To see your repository changes, or commit, simply chdir to the package's root directory:

$ cd vendor/author/package-name $ git status

Now, if you try to list the available remote repositories, you will notice that there are two of them: composer and origin. So if you want to push something, make sure you push to origin.

$ git remote composer origin $ git push origin development

If you use PhpStorm while coding, you are probably working with its awesome git client. In this case you will notice that changes you do to your composer package will not be shown in your project's diff list. Of course they won't, those changes belong to a different repository.

Phpstorm's git client is not able to check two repositories simultaneously

Phpstorm's git client is not able to check two repositories simultaneously

Here is what I do in this case: I just open a second PhpStorm project (File -> Open) and select as directory the root of the package, that is the directory containing your package's composer.json file.

That's it! Happy coding!

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.125.0. UTC+08:00, 2024-05-03 13:30
浙ICP备14020137号-1 $访客地图$