Screening Entry Level

How does Symfony handle environment-specific configuration? Explain the relationship between .env files, environment variables, and the config/packages structure.

Quick Tip

Show the precedence: "Real env vars override everything. For dev, .env provides defaults, .env.local overrides them locally. In production, I set real environment variables through the hosting platform — never rely on .env files."

What good answers include

Symfony loads .env files in a specific order: .env (defaults), .env.local (local overrides, gitignored), .env.{env} (environment-specific), .env.{env}.local (local environment overrides). Real environment variables always take precedence over .env files. Config files under config/packages/ can be environment-specific: config/packages/prod/monolog.yaml only loads in prod. The APP_ENV variable determines which environment is active. Strong candidates explain: that .env files are for development convenience and production should use real environment variables, the %env()% syntax in service configuration, and env var processors (bool, int, json, file, etc.).

What interviewers are looking for

Baseline Symfony knowledge. Candidates who commit secrets to .env files or do not understand the loading order will create configuration bugs across environments. Ask how they handle secrets in production.

← All Symfony questions