A deployment can interrupt service even when the new PHP code is correct. File replacement during active requests, incompatible database migrations, stale workers, and cache changes can all cause errors. Zero-downtime techniques reduce interruption, but they require a release process designed around compatibility and rollback.
Use versioned releases
Keep each deployment in its own release directory and switch a current symlink only after the new release is ready:
/app/releases/2026-11-22-1200/
/app/releases/2026-11-22-1430/
/app/current -> /app/releases/2026-11-22-1430/
Build dependencies and run tests before switching. Keep persistent uploads, logs, and environment configuration outside the release directory so a new release does not overwrite runtime data.
Make database changes compatible
Use an expand-and-contract migration. First add new nullable columns or tables while the old code still works. Deploy code that can read both old and new representations. Backfill data in controlled batches, then remove obsolete fields only after all application instances and workers have moved to the new version. A destructive migration can make rollback impossible even if the code symlink is reverted.
Switch traffic and workers deliberately
Ensure the new release has correct permissions, configuration, and dependencies before changing the symlink. Reload PHP-FPM gracefully if opcode cache or worker behavior requires it. Queue workers should be restarted or drained in a controlled manner so old processes do not continue executing outdated code against a changed schema.
Verify and roll back
Run health checks and test critical user journeys immediately after the switch. Watch error rates, response times, queue age, and database errors. Keep the previous release available until the new version is stable. A rollback plan must include database compatibility and background jobs—not just switching a symlink back.
On shared hosting, true atomic releases may not be available. Use the safest supported maintenance or staged-upload method and avoid claiming zero downtime unless the entire deployment path has been tested.