Automated deployment of a Laravel web application

Warning: You are reading an outdated version of this guide. Unless you're here for a specific reason, you probably want the updated version instead.

This guide covers three workflows for (re)deployment of your app. Read through the summaries below and pick the best one for you.

Option 1: Super simple redeployment

Article: Super simple redeployment

Summary: deployment is triggered by a Git push to the server’s Git repo and managed with a server-side Git hook. The app is rebuilt and updated in the same directory from which you serve it.

Features: simplicity; but the app goes down for a minute or so during each redeployment, and a failed redeploy will keep your app down until you perform manual intervention.

Use case: as an introduction to Git hooks and automated redeployment. Use this as a learning exercise but not for a production app.

Option 2: Zero-downtime redeployment using Git hooks

Article: Zero-downtime redeployment using Git hooks

Summary: deployment is triggered by a Git push to the server’s Git repo and managed by a server-side Git hook. The app is built in an offline directory and only published if the build completes successfully.

Features: redeployment is practically instant (the time it takes to create a symlink). A failed redeploy won’t bring your app down—you’ll just continue serving the previous version and your users will be none the wiser. You can also roll back to previous releases, but this requires manual intervention.

Use case: primarily as an introduction to zero-downtime deployment. But, despite its simplicity, you could probably use this in production for a low-stakes application (that doesn’t require a staging server, say).

Option 3: Zero-downtime deployment using Deployer

TLDR: here is the article—it’s by Loris Leiva and super cool.

Summary: Deployer is an open source tool for deploying PHP applications; it’s more powerful and probably a more appropriate choice for serious projects than the roll-your-own workflows in options 1 and 2. The downside is additional complexity—you have to learn to use a new tool.

Article: I actually have a whole series for you here, but it’s not mine—Loris Leiva has written an excellent guide to deploying a Laravel application using Deployer (and also covers two other payable deployment tools—Ploi and Laravel Forge). Instead of trying to reinvent the wheel I’ll refer you to his guide instead: you can either read the whole series or just the zero-downtime redeployment article. This would be good reading even if you don’t end up using Deployer, just to see the content of my guide from a different perspective.

Finding this tutorial series useful? Consider saying thank you!

The original writing and media in this series is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.