Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 stop Composer installing parameters.yml.dist into parameters.yml

New in symfony 2.3 the composer install script also copies the parameters.yml.dist file contents into the parameters.yml file, explained further here.

My question is, how can I stop composer preforming this action?

like image 626
Andrew Atkinson Avatar asked Jul 03 '13 15:07

Andrew Atkinson


2 Answers

Remove this line twice from your composer.json:

"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",

This is done by the IncenteevParameterHandler library, which contains a script that does this. By removing the script from the config, it will never be called.

If you remove that line for ever, you can also remove these lines (as the library isn't really needed anymore):

"incenteev/composer-parameter-handler": "~2.0",

...

"incenteev-parameters": {
    "file": "app/config/parameters.yml"
},
like image 66
Wouter J Avatar answered Oct 09 '22 16:10

Wouter J


First solution : add "keep-outdated": true in the 'extra' section of your composer.json.

[...]
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml",
        "keep-outdated": true  <------------ ADDED LINE ------------
    },
    "branch-alias": {
        "dev-master": "2.3-dev"
    },
    "symfony-assets-install": "symlink"
}
[...]

incenteev will not remove parameters any more.

Second solution : modify the app/config/parameter.yml.dist file. For me it was to add Sqlite parameters 'path' and 'memory' and avoid to see them deleted each time I do a composer update.

# app/config/parameter.yml.dist
parameters:
    database_driver:   pdo_sqlite
    database_host:     ~
    database_port:     ~
    database_name:     ~
    database_user:     ~
    database_password: ~
    database_path:     ~ <------------ ADDED LINE ------------
    database_memory:   ~ <------------ ADDED LINE ------------
[...]

I don't know which solution is the best but both works.

like image 34
David Jacquel Avatar answered Oct 09 '22 17:10

David Jacquel