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.

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.

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": "*"
...
}

Nextly we run composer install

composer install

And one of the changes you should note that your dependency comes from /tmp/loaders instead of public repository.

Take alytvynov/loaders from local path.

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:

Thank you for your attention.

LinkedIn, Twitter, https://lytvynov-anton.com

Senior web developer, architect, cryptocurrencies trader, https://lytvynov-anton.com