Deploying to production is not just uploading files. There are specific steps that make your app significantly faster and more reliable.
Run these commands on every deploy
composer install --no-dev --optimize-autoloader
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan event:cache
These commands pre-compile your configuration, routes, views, and event listeners. Instead of parsing files on every request, Laravel loads pre-built, cached versions.
Set the right environment variables
APP_ENV=production
APP_DEBUG=false
APP_URL=https://yourdomain.com
CACHE_DRIVER=redis
SESSION_DRIVER=redis
QUEUE_CONNECTION=redis
Never run with APP_DEBUG=true in production. It exposes sensitive information in error pages.
Database optimizations
Run migrations with zero downtime in mind. For large tables, use the --pretend flag first to see what SQL will be executed. Add indexes before adding large amounts of data, not after.
Queue workers and Horizon
Use Supervisor to keep queue workers running and restart them if they crash. Configure it to use multiple workers for high-volume queues.
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/artisan queue:work redis --sleep=3 --tries=3
autostart=true
autorestart=true
numprocs=4
Monitor everything
Set up error monitoring with Sentry or Bugsnag. Monitor queue depth and processing time. Set alerts for high error rates. You should know about production problems before your users do.
Deployment checklist
Before every deploy: run your test suite, review the migration, check environment variables are set, and have a rollback plan. A deployment that takes 5 minutes with proper checks is better than one that takes 1 minute and breaks production.



