Laravel interview question · Most asked

How do you deploy a Laravel application with zero downtime?

Summary

Build each release in a new directory (dependencies installed, assets built, config cached), run backward-compatible migrations, switch a symlink atomically, reload PHP-FPM/OPcache, and restart queue workers. Tools such as Envoyer, Deployer or Forge automate this.

Longer Answer

Steps for a typical server deploy:

  1. Clone to releases/<timestamp>; link shared .env and storage/.
  2. composer install --no-dev --optimize-autoloader, build front-end assets.
  3. php artisan optimize.
  4. php artisan migrate --force (expand-only changes).
  5. Atomically switch the current symlink; reload PHP-FPM so OPcache picks up the new files.
  6. php artisan queue:restart (or horizon:terminate), and octane:reload if used.
  7. Health check; keep the previous release for instant rollback.

In containers the same ideas apply: an immutable image, migrations as a separate step, rolling updates with readiness probes, and graceful worker shutdown (SIGTERM handling).

Key Points

  • New release directory + atomic symlink switch.
  • Migrations compatible with old code.
  • Reload FPM/OPcache; restart workers.
  • Keep the previous release for rollback.

More most-asked Laravel questions

← All Laravel questions