Deployment

Contents
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

Related articles
Development with PHP
What is Laravel and where it runs
Install Laravel
Your first route
Controllers
Blade basics
Blade advanced
Migrations
Eloquent models
Relationships
Query builder
Seeders and factories
Validation
Auth intro
Hand-rolled login
Middleware
Service container
Config and env
Artisan commands
Events and listeners
Queues
Mail
Cache
Sessions in Laravel
CSRF
Hashing
Sanctum tokens
API resources
Gates and policies
Notifications
Scheduler
Filesystem
Localization
Testing
HTTP tests
Collections
Carbon dates
Pagination
File uploads
Eloquent advanced
Transactions and locks
Deployment
Debugbar and dd
Broadcasting
Full-text search
Capstone: blog
Capstone: JSON API
Capstone: shop cart
Performance: kill N+1
Modern Laravel tour
Hero roadmap: the whole course on one page
Banner image

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: