Use your bundle locally by path in composer
Composer symlink for packages
I cross around the net and could not find fast the solution for using package locally instead of passing by packagist(satis, any other hub).
Let’s imagine the situation when you have project and bundle you code yourself for it. Let’s say your project s1 and your bundle is loaders.
It’s not really comfortable to code without executing the final bundle code in your project. You need pass by repository, merge your changes, CI/CD pipelines, so on… just to execute it.
Use composer symlink
The solution I found using your bundle directly in your project during development and not by repository.
You can add a symlink to the bundle in your project compose and simply run composer install. Simply add repositories section to composer.json
"repositories": [
{
"type": "path",
"url": "/tmp/loaders",
"options": {
"symlink": true
}
}
],
Where /tmp/loaders is the path to your dependency.
A few packages
If you have a folder which contains multiple packages then you can set the folder of packages
"url": "path/to/your/packages/*"
Next you have to update the "require"
or"require-dev"
section.
"require": {
...
"your/package": "*"
...
}
Composer install
Nextly we run composer install
And one of the changes you should note that your dependency comes from /tmp/loaders instead of public repository.
That’s it, now when you change the code in your loaders folder you ll see the modifications immediately in your project.
Result — Repositories
You can check the code for this part here:
- Project https://github.com/alytvynov/s1
- Dependency https://github.com/alytvynov/loaders
Thank you for your attention.
Need professional help in web or mobile development?
Recommendation for planning or estimation of your project?
Feel free to contact me here.