Deployment
| 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