Ben Sampson has posted a quick guide on his site sharing a deployment script for Laravel applications he's found useful.
A good deploy script can save you time and speed up your application, and it only takes a few minutes to set one up.
I have a standard deploy script which I use for almost all of my projects, which I'm going to break down and share with you.
Note: This article assumes that you're using Laravel Forge. If you're not, many of the settings will be applicable, but the setup steps may be a bit different.
He starts with a brief description of what a deployment script is and goes through the functionality he has included in his:
- switching the site to maintenance mode
- clearing caches
- clearing and optimizing routes
- clearing and optimizing the configuration
- clearing expired password reset tokens
- compiling front-end assets
He puts it all together into a single file that's then included in the Forge deployment process. He doesn't provide other instruction as to how to use this script with another deployment method but it can potentially be used anywhere a bash script could.