Courses

[NEW] Laravel Project PROCESS: From Start to Finish

Zero-Downtime Deployment with Envoyer

Summary of this lesson:
- Setting up Envoyer deployment
- Configuring deployment hooks
- Managing server cleanup
- Implementing zero-downtime updates

Our client was happy with the deployment, but they were not happy that the website was down for a while, during the deployment. And that makes sense! We have our script set up to take our application down:

cd /home/forge/v2.linksletter.com
if [ -f artisan ]; then
$FORGE_PHP artisan down
fi
 
git pull origin $FORGE_SITE_BRANCH
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader
 
npm install
npm run build
 
rm -rf /node_modules
 
if [ -f artisan ]; then
$FORGE_PHP artisan cache:clear
$FORGE_PHP artisan view:clear
$FORGE_PHP artisan route:cache
$FORGE_PHP artisan config:cache
$FORGE_PHP artisan view:cache
fi
 
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
 
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
$FORGE_PHP artisan up
fi

Specifically, the artisan down and artisan up commands. They take our application into maintenance mode for a few minutes. Let's look at Forge's deployment history:

It takes 10-20 seconds; imagine if our application grew in complexity and size. This can grow exponentially!

So, what are our solutions? We can use a zero-downtime deployment tool like official Laravel Envoyer.

There are also other alternatives:

But for this tutorial, we chose Envoyer because it's a first-party tool from Laravel team.

Let's set it up!


Configuring Envoyer

To set up Envoyer, we must go to the Envoyer website and sign up for an account. Once we have an account, we can start the...

The full lesson is only for Premium Members.
Want to access all 16 lessons of this course? (105 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord