Converting a Composer dependency to git for editing
I’m adding a new feature to ZF’s Problem-Details component and it’s easiest to do this within the context of the application I’m developing.
The component lives in vendor/zendframework/zend-problem-details and was installed using composer require so doesn’t have its own git repository as the distribution zip file was used to install it.
To change it to a git repository, we can use the --prefer-source option and specify a branch like this:
$ composer require --prefer-source zendframework/zend-problem-details:dev-master
I now have a git checkout of the component with two remotes: origin and composer. I changed origin to my fork and then create a branch to work on:
$ cd vendor/zendframework/zend-problem-details $ git remote rm origin $ git remote add origin firstname.lastname@example.org:akrabat/zend-problem-details.git $ git checkout -b my-new-feature
We’re now off the races and I can easily develop my new feature and push to origin as normal and then hopefully raise a PR.