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

wreckless's avatar

How to configure composer.json for product deployment

Hi All,

In my composer.json file I have a few scripts listed under "post-autoload-dump". Some of these are specific to my dev environment, like generating an ide-helper file, which depends on a require-dev package. When I deploy to production, I don't want scripts like that running. I'd also like to add more scripts for optimizing production, like artisan config:cache, for example, but only in my production environment. How can I have different composer post-autoload-dump scripts run based on environment? Or do I have to change my composer file each time I push it to prod? Or are there other/better strategies to accomplish the same thing? Thanks in advance.

0 likes
0 replies

Please or to participate in this conversation.