Every two weeks I send out a newsletter containing lots of interesting stuff for the modern PHP developer. You can expect quick tips, links to interesting tutorials, opinions and packages. Want to learn the cool stuff? Then sign up now!

How to set up your Laravel application for zero-downtime deploys

On his blog Matt Stauffer published a new post explaining the steps required to deploy your app without any downtime.

The reason you’re getting zero-downtime deploy from these tools is because the entire deploy process—clone, composer install, etc.—doesn’t happen in the directory that is currently serving your site. Instead, each new release gets its own separate “release” directory, all while your site is still being served from its current “release” directory.

https://mattstauffer.co/blog/how-to-set-up-your-laravel-application-for-zero-downtime-envoyer-capistrano-deploys

In my own projects I handle these capistrano like deploys using a custom Envoy script:
https://github.com/spatie/blender/blob/master/Envoy.blade.php

Freek Van der Herten is a partner and developer at Spatie, an Antwerp based company that specializes in creating web apps with Laravel. After hours he writes about modern PHP and Laravel on this blog. When not coding he’s probably rehearsing with his kraut rock band. He loves waffles and butterflies.
  • Thank you for sharing!
    We are happy with Deployer
    https://deployer.org/blog/how-to-deploy-laravel

  • Potsky Mac

    Oops! NEVER do this! You cannot migrate the database in this way. In the time between the artisan migrate command and the folder link creation, the code is in version 1 and the database in version 2. Requests handled during this time will create broken version 1 objects in a version 2 database. In the worth case, there will be no error and in several months, you will have a headache to understand why database is corrupted.

    With the same idea, the storage folder should not be kept if there are cached data inside. Cached object will be stored in version 1 format and code will run version 2…

    Silent upgrades can only be performed if there is no database migration and no cached objects.