Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer: specify local repository when in development, and packagist when in production?

Here's the basic story: I develop some package that I also use in projects. Those packages are published to packagist, and when I use them in my projects, I just require them as any other package.

When the projects are on the development server, it's all good, they get the latest version and just works.

But when I'm developing, I find that waiting for packagist to update, and requiring do go composer update everytime I do something over my package is a bit of a waste of time... Normally, I'd setup a custom vcs repository pointing to the local path on my hard drive and be done with it, but doing so I need to keep in mind that I have to remove said local repository before pushing to production.

What's I'd like to achieve (if possible, or something that would do the same!) is to have some package in the require section of my composer.json to use packagist when in prodcution, and have the require-dev section to only use the local repository.

Is that possible? I honestly could not find anything related to that in the docs... Or I just misread the usage of it all.

like image 970
Jean-Philippe Murray Avatar asked Apr 18 '17 15:04

Jean-Philippe Murray


1 Answers

I'm adding this a solution, but will keep the question unanswered for a while hoping for vanilla solution.

Basically, I can achieve what I wanted using this package. What it does is help you specify local paths to look for packages and steps in when you are doing composer update. And since this is only locally installed (with composer global), it leaved the production server to normally resolves the package with packagist.

like image 62
Jean-Philippe Murray Avatar answered Sep 22 '22 12:09

Jean-Philippe Murray