DEV Community


Posted on • Originally published at Medium on

Use the release phase to automate your release in your Laravel app

Laravel on Heroku — Tip #2

On Heroku the release phase allows you to run certain tasks before a new release of your app is deployed.

Release phase can be useful for tasks such as:

  • Run the database migrations
  • Clear cache
  • Sending CSS, JS, and other assets from your app’s slug to a CDN or S3 bucket

In our Laravel app, we will run the database migrations and flush the application cache.

Add the following line to your Procfile:

release: php artisan migrate --force && php artisan cache:clear
Enter fullscreen mode Exit fullscreen mode

The main advantage of using the release phase:

If the release command exits with a non-zero exit status, or if it’s shut down by the dyno manager, the release fails. In this case, the release is not deployed to the app’s dyno formation. You will receive an email notification in the event of a release phase failure.

Want more tips like these?

You should follow me on Twitter! And if you’re building on Heroku, you should check out AutoIdle — the automated way to save money on your staging and review apps.

Discussion (0)