Generate parameters.yml files in Symfony

The best practice in Symfony with the parameters.yml file is to create a parameters.yml.dist file and generate the parameters.yml from it. But how do you do this?

With the ParameterHandler from Incenteev.

To use it, just put the following into your require part of your composer.json

"require": {
    "incenteev/composer-parameter-handler": "~2.0"
}

After a composer update use the following settings to automatically run an update on the parameters.yml on every composer install and update. In the extra part of the configuration we define which file to use and that we want to keep parameters which are already defined.

"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
    ]
},
"extra": {
    "incenteev-parameters": {
        "file": "app/config/parameters.yml", // required
        "keep-outdated": true
    }
}
comments powered by Disqus