Configuring Symfony (and Environments)

Every Symfony application consists of a collection of bundles that add useful tools
(services) to your project. Each bundle can be customized
via configuration files that live - by default - in the app/config directory.

Most top-level keys - like framework and twig - are configuration for a
specific bundle (i.e. FrameworkBundle and TwigBundle).

Configuration Formats

Throughout the chapters, all configuration examples will be shown in
three formats (YAML, XML and PHP). YAML is used by default, but you can
choose whatever you like best. There is no performance difference:

Another special key is called parameters: it's used to define variables that
can be referenced in any other configuration file. For example, in config.yml,
a locale parameter is defined and then referenced below under the framework
key:

YAML

1
2
3
4
5
6
7
8
9
10
11
12
13

# app/config/config.yml# ...parameters:locale:enframework:# ...# any string surrounded by two % is replaced by that parameter valuedefault_locale:"%locale%"# ...

But the parameters.yml file is special: it defines the values that usually
change on each server. For example, the database credentials on your local
development machine might be different from your workmates. That's why this file
is not committed to the shared repository and is only stored on your machine.

Because of that, parameters.yml is not committed to your version control. In fact,
the .gitignore file that comes with Symfony prevents it from being committed.

However, a parameters.yml.dist file is committed (with dummy values). This file
isn't read by Symfony: it's just a reference so that Symfony knows which parameters
need to be defined in the parameters.yml file. If you add or remove keys to
parameters.yml, add or remove them from parameters.yml.dist too so both
files are always in sync.

The Interactive Parameter Handler

When you install an existing Symfony project, you
will need to create the parameters.yml file using the committed parameters.yml.dist
file as a reference. To help with this, after you run composer install, a
Symfony script will automatically create this file by interactively asking you
to supply the value for each parameter defined in parameters.yml.dist. For
more details - or to remove or control this behavior - see the
Incenteev Parameter Handler documentation.