I hope my question is not too vague, but can't get a proper answer by searching.
I have the following situation; We are working on a project and have certain dependencies installed through Composer. One of these dependencies is quite outdated and requires some fixes and additions. I have forked this repo on GitHub and added it to Packagist.
To work on the code, I need it running in my project and edit from there to see if my changes work, but it is in the vendor
folder, where it is installed through composer.
Cloning this project through GitHub directly in the vendor folder won't work, as the autoloader won't be written for it.
What I have done so far is working in the vendor
folder, and then copying and pasting my work from there to the GitHub folder and pushing from there, but logistically quite tricky.
How does one work on a composer library that is embedded in a project, in such a way that you can commit your changes from this folder?
Change package constraint in
composer.json
to use branch instead of tagged version - you can usedev-master
formaster
branch ordev-my-branch
formy-branch
branch. You may also configure branch alias.Add a repository which points to your fork:
Run
composer update
to install new version from your fork (orcomposer require "some-vendor/some-package:dev-master"
if you don't want to update any other dependencies).Now you should have sources cloned from your fork in
vendor/some-vendor/some-package
. You can edit these files and test if changes fits to your app. After you finish your work:composer update
orcomposer require "some-vendor/some-package:dev-master"
. This will update yourcomposer.lock
file to use latest version of your fork. Then commit changes in your lock and push.Now if someone will clone your project (or just pull changes) it will get new
composer.lock
pointing to your fork with specified commit hash -composer install
should always install the same version of your fork directly from GitHub.