PHP › Deployment & Hosting for PHP Applications

What steps are typically involved in a standard PHP application deployment process, from code changes to a live production update?

Intermediate

Answer

A typical deployment process involves running the application's test suite to verify the code changes have not introduced any regressions, running Composer to install production dependencies with development tools excluded, running any necessary database migrations, clearing and rebuilding application caches, and then switching production traffic over to the newly deployed code, often using a technique like a symlink swap that allows for near instant rollback if something goes wrong immediately after deployment.
composer install --no-dev --optimize-autoloader
php artisan migrate --force
php artisan config:cache
ln -sfn /var/www/releases/new /var/www/current
Real-world example A company automates its deployment process so that every code change merged to the main branch automatically runs through this exact sequence of steps, ensuring consistency and eliminating the risk of a manual deployment step being accidentally forgotten.

Common follow-ups: What is a symlink based deployment strategy and why does it enable fast rollback?;How do you safely run database migrations during a live deployment without downtime?