Deployment
| Deploy checklist | |
| Prod env | |
| Cache everything | |
| Migrate with force |
Deploy checklist
A calm deploy is a checklist, not a memory test. Freeze merges, run the test suite, tag the release, install only production dependencies, warm the caches, run migrations, then smoke test the home page and one form.
Print the list and tick boxes in order. When a step fails, the paper tells you exactly where the deploy stands, and the fix starts from a known point instead of a vague feeling.
1. Freeze merges and tag the release 2. composer install --no-dev 3. php artisan config:cache 4. php artisan route:cache 5. php artisan view:cache 6. php artisan migrate --force 7. Smoke test the home page and one form
Prod env
Production differs from your laptop in three settings: the environment name, the debug flag, and the application key. Set APP_ENV to production, APP_DEBUG to false, and keep a fresh random APP_KEY that never enters version control.
Read values through the env helper with safe local defaults, so a missing variable fails loudly on your machine instead of quietly in production:
$env = env("APP_ENV", "local"); $debug = env("APP_DEBUG", false); if ($debug) { echo "Debug is on - disable it in production"; } echo $env;
Cache everything
Laravel parses configuration, routes, and views on every request, so production keeps compiled copies of all three. Run the three cache commands after every deploy, and re-run them whenever the underlying files change.
php artisan config:cache
Configuration cached successfully
php artisan route:cache
Routes cached successfully
php artisan view:cache
Blade templates cached successfully
Skip these commands on your laptop while you are still editing, or you will debug stale copies of files you already fixed.
Migrate with force
Migrations never stop to ask questions on a server, so the force flag is your written confirmation that you mean it. Back up the database first, run one command, then verify that the newest batch landed before opening the site to traffic.
Keep the backup from this exact deploy until the next one succeeds. A known-good snapshot turns a bad migration from a disaster into a short restore story.
php artisan migrate --force
Migrated: 2026_01_01_000001_create_posts_table
Next: Debugbar and dd
Article author: Arthur Isaev