Use the release phase to automate your release in your Laravel app
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
The main advantage of using the release phase:
releasecommand 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.