Deployment

Contents
Deploy checklist
Prod env
Warm cache
Migrate on deploy

Deploy checklist

Deploy in the same order every time: vendors without dev tools, production settings, fresh cache, compiled assets, database migration. The checklist below fits most small projects and grows with them.

1. composer install --no-dev

2. set APP_ENV prod, 3. cache clear, 4. assets compile, 5. migrate

Prod env

Production settings live in environment variables, not in code. APP_ENV=prod switches Symfony to production mode, and APP_SECRET must be a long random string that never lands in version control.

APP_ENV=prod, APP_SECRET set to a long random string

DATABASE_URL points at the production database

Warm cache

Clear and warm the cache during deploy, never on the first visitor. The command rebuilds the container and the route cache before traffic arrives, so the first real request is already fast.

$ php bin/console cache:clear

Cache cleared for the prod environment

Migrate on deploy

Run migrations as a deploy step with no questions asked, so the schema always matches the code. Keep every migration reversible and test it on a database copy first, not on live data.

$ php bin/console doctrine:migrations:migrate --no-interaction

Migrated to the latest version, no pending migrations

Next: Performance

Article author: Arthur Isaev

Related articles
Development with PHP
What is Symfony and where it runs
Install Symfony
Your first page
Routes
Controllers
Twig basics
Twig advanced
Doctrine setup
Entities
Migrations
Repositories
Relations
Forms
Validation
Services and DI
JSON controllers
Serializer
Security intro
Users
Login form
Voters
Console commands
Events
Messenger
Mailer
Cache
Sessions
CSRF
Translations
Dotenv and env
Profiler
Testing
Fixtures
Pagination
File uploads
API Platform in one lesson
DQL
Transactions
Migrations advanced
Security advanced
HTTP client
Scheduler
Webhooks
Asset Mapper
Deployment
Performance
Capstone: blog
Capstone: JSON API
Modern Symfony tour
Hero roadmap: the whole course on one page

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: