New in Symfony 2.3: Interactive Management of the parameters.yml File
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
One of the best practice when developing a Symfony application is to make it
configurable via a
parameters.yml file. It contains information such as
the database name, the mailer hostname, and custom configuration parameters.
As those parameters can be different on your local machine, your testing
environment, your production servers, and even between developers working on
the same project, it is not recommended to store it in the project repository.
Instead, the repository should contain a
paramaters.yml.dist file with
sensible defaults that can be used as a good starting point for everyone.
Then, whenever a developer starts working on the project, the
parameters`.yml file must be created by using the
as a template. That works quite well, but whenever a new value is added to the
template, you must remember to update the main parameter file accordingly.
As of Symfony 2.3, the Standard Edition comes with a new bundle that automates
the tedious work. Whenever you run
composer install, a script creates the
parameters.yml file if it does not exist and allows you to customize all
the values interactively. Moreover, if you use the
it will silently fallback to the default values.
Please remember that storing password or any other sensitive information in
parameters.yml file is not a good idea, and Symfony provides other
ways to do the same in a more secure way.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.