Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Phillipp's avatar

Composer - use different composer.json files

Hey,

is there a way to use another composer file, for example composer.dev.json?

The reason: I build an app based on lumen. And for this app I will create some packages. This packages are in the vendor folder so I can use it in my Lumen app. So for local development I can't require a version of these packages in my composer.json because they aren't online yet. But when I publish the packages and the main application I need the require entry in the composer.json.

Yes I can edit the composer.json before a push but that is crap in my mind. Having an extra composer.json file for local development sounds better.

Is there a way to do this? Can't find one.

0 likes
2 replies
BENderIsGr8te's avatar

Curious....

Composer specifically has a section for "require-dev". Let's say I want to load a package Clockwork only to be used in my dev environment, I would install it like this....

composer require Clockwork/Clockwork --dev 

This would then add it to my Composer.json file under a special section

"require-dev": {
    "clockwork/clockwork": "~2.0",
    },

If I run a simple composer update or composer install command, it will install and/or update everything (including this require-dev block). However, on the production server, you run

composer update --no-dev

(or composer install --no-dev) and nothing in the require-dev block will be imported into your listing.

For sanity purposes, it seems much easier to only maintain one Composer.json file and simply run the proper command for your server when running installing or updating.

Any reason this wouldn't work for your application?

Please or to participate in this conversation.