Lesson 3 of 9 · 20m
Configuration, Environments, and Debug Tooling
Bundles, config packages, environment variables, cache warmup, and the profiler tools that keep local behavior close to production.
Most Symfony outages blamed on "the framework" are configuration drift: local used SQLite, production used Postgres; local disabled a cache, production optimized something away. Senior Symfony work is making environments boringly similar.
Configuration is layered, not duplicated
config/
packages/ # shared baseline
doctrine.yaml
messenger.yaml
packages/dev/ # deliberate differences only
packages/prod/
services.yamlCopying whole files into every environment guarantees silent divergence. Put the common case in config/packages and keep environment overrides small enough to review.
Env vars are deployment input
DATABASE_URL="postgresql://app:password@127.0.0.1:5432/app?serverVersion=16"
MAILER_DSN="smtp://localhost:1025".env is for safe defaults and local development, not production secret storage. Real deployments inject values through the host, container platform, or secret manager. Remember that some values are needed during container compilation, not only at runtime.
Cache is part of the runtime model
APP_ENV=prod composer install --no-dev --optimize-autoloader
APP_ENV=prod php bin/console cache:clear
APP_ENV=prod php bin/console cache:warmupProduction Symfony compiles the container, routes, templates, and metadata. If cache:clear is your routine production fix, the deployment pipeline is incomplete or application code is reading mutable configuration it should not read.
The profiler is local truth serum
The profiler records timeline, queries, events, security decisions, mail, messenger messages, cache, and deprecations. Learn it before the incident. debug:config and debug:container show effective configuration rather than intended configuration:
php bin/console debug:config doctrine
php bin/console debug:autowiring MailerInterface --allField notes
- Commit safe defaults in
.env; keep local overrides in.env.localand secrets outside git. bin/console aboutis the fastest environment fingerprint during support work.- Avoid
if kernel.environment === prodin business logic; inject explicit feature configuration instead. - Treat profiler deprecations as upgrade debt, not noise.
- When prod alone misbehaves, inspect compiled cache and environment variables before blaming PHP.
Was this lesson helpful?