47

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?

4 Answers 4

78

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"
},
1
  • 7
    It's not though. All that's happening is that Composer now won't call the buildParameters method of the ScriptHandler. It's not even part of the core symfony code, it's a 3rd party bundle. (So it's removal won't have any side-effects.) It's included in the standard distro though, since it's really useful when working in teams - even if it's just 2 people -, so ultimately I wouldn't recommend removing this functionality.
    – ZeeCoder
    Nov 2, 2014 at 0:54
58

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.

1
  • 15
    I like the second solution the best as it forces you to manifest all your project's parameters in the parameter.yml.dist so that everyone who exports your project knows about them.
    – flu
    Dec 11, 2013 at 10:34
4

leaving empty this array of parameters:

"incenteev-parameters": {
    "file": "app/config/parameters.yml"
},

in the extra section of your composer.json file should work.

"incenteev-parameters": {},
0
2

This is the correct solution in my opinion:

"incenteev-parameters": {
    "file": "app/config/parameters.yml",
    "keep-outdated": true
},

It was mentioned in this github issue https://github.com/symfony/symfony-standard/issues/642 as well as in the github documentation for incenteev-parameters https://github.com/Incenteev/ParameterHandler

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.