Configuration and environments

← Configuration and environments

Ashterix

feat(seo): og:image size for front matter images; short titles and explicit descriptions for From Magento to Symfony

en/articles/magento-to-symfony/core/config.md +2 −1

Configuration and environments

Configuration has two levels. Bundle config (config/packages/*.yaml) describes how the framework is set up and is read when the container is compiled. Environment variables (%env(...)%) hold what differs between servers and are read at runtime.

Magento · a value from the admin

$enabled = $this->scopeConfig->isSetFlag(
    'faq/general/enabled',
    ScopeInterface::SCOPE_STORE
);

Symfony · a value from the environment

# .env
FAQ_ENABLED=1
final class FaqMenu
{
    public function __construct(
        #[Autowire(env: 'bool:FAQ_ENABLED')]
        private bool $enabled,
    ) {}
}
  • File order: .env → .env.local → .env.$APP_ENV → .env.$APP_ENV.local. Real environment variables win over all files. .env is committed, *.local is not.
  • Processors: %env(int:X)%, bool:, json:, resolve:, default:fallback_param:X.
  • Secrets: bin/console secrets:set ERP_TOKEN encrypts the value in the repository, the decryption key lives only on the server.
  • Environments: a when@prod: block in any YAML or the #[When(env: 'dev')] attribute on a class.
  • Prod: composer dump-env prod builds .env.local.php so the files aren't parsed on every request.
  • Reference: debug:config framework shows the actual values, config:dump-reference doctrine shows all possible options.
There are no admin settings

If the business needs settings that a person changes in the browser, that is an ordinary entity, table, form and cache that you write yourself. There are no store/website scopes either: a multi-store or multi-tenant setup is designed separately.