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

raniesantos's avatar

How do I automate these commands when deploying to Heroku?

I'm using Heroku and I'm able to deploy fine with it.

But I noticed I have this repetitive process of running php artisan config:cache and php artisan route:cache whenever I do.

Which file should I add these commands to in order to automate them?

In composer.json? In the Procfile?

0 likes
2 replies
knox's avatar

I've always stuck them in the composer.json file in the post-install-cmd without any issue.

For example:

"post-install-cmd": [
      "Illuminate\Foundation\ComposerScripts::postInstall",
      "php artisan optimize",
      "php artisan migrate --force"
    ],
1 like

Please or to participate in this conversation.