I have some custom entries in my parameters.yml, every time I run a composer update, it wants to add the missing entries, which even worse overwrites my custom entries. How can I stop this?
e.g. before composer update
#parameters.yml
# Env = GLOBAL
parameters:
# DB settings - GLOBAL
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
#mailer settings
mailer_to: [email protected]
mailer_from: [email protected]
mailer_transport: smtp
mailer_subject: ":-| Something is broken!"
# Framework use - GLOBAL
locale: en
after
#parameters.yml
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
mailer_transport: smtp
locale: en
database_name:
database_user:
database_password:
mailer_host:
mailer_user:
mailer_password:
secret:
Luckily my repo and my working file through my ide are two different files and need to be synced. after i run composer update, when i run a sync, i download all files to my IDE except for the parameters.yml, that one i push back up to overwrite the one that was just auto created.
I would like to eliminate this hassle, as I keep my db passwords on a per/env file.
EDIT: When I try to fill in the unneeded vars as dummy values by nulling them out, it backfires as well.
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
Updating the "app/config/parameters.yml" file
Some parameters are missing. Please provide them.
database_name: null
database_user: null
database_password: null
mailer_host: null
mailer_user: null
mailer_password: null
secret: null
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "mailer_from".
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
The custom param is causing problems itself as well.
So now I go to peek at my newly generated file, and it looks like this
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
mailer_transport: smtp
locale: en
database_name: null
database_user: null
database_password: null
mailer_host: null
mailer_user: null
mailer_password: null
secret: null
But what i need it to say after regenerating ideally is this
/**
* my custom comment and copyright/legal tamper warning
*/
# Env = GLOBAL
parameters:
# DB settings - GLOBAL
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
#mailer settings
mail_to: [email protected]
mail_from: [email protected]
mail_transport: smtp
mail_subject: ":-| Something is broken!"
# Framework use - GLOBAL
locale: en
The rest of my parameters are located on another parameters file, that is dynamically included depending on what env loads, and has different db creds on them each.
EDIT per @AlpineCoder answer: my latests findings why adding dummy values doesnt work
When I add this to my parameters.yml
#dummy values to avoid regeneration
database_name: dummyvalue
database_user: dummyvalue
database_password: dummyvalue
mailer_host: dummyvalue
mailer_user: dummyvalue
mailer_password: dummyvalue
secret: dummyvalue
It no longer asks me to fill in these values, thats great, however, it still regenerates the file, deleting all my custom values, leaving me with this
# This file is auto-generated during the composer install
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
mailer_transport: smtp
locale: en
database_name: dummyvalue
database_user: dummyvalue
database_password: dummyvalue
mailer_host: dummyvalue
mailer_user: dummyvalue
mailer_password: dummyvalue
secret: dummyvalue
You have two options, either fill out your parameters.yml.dist or you can go to your composer.json file and in the post-update-cmd and post-install-cmd you should see something like
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
if you remove that line, your parameters will no longer be changed when you run composer.
If you're collaborating with other people, updating your parameters.yml.dist will probably be the better way to go though as it will help remind them they need to fill out new parameters when new ones are introduced.
If you add the custom parameters (and a default / dummy value) to the parameters.yml.dist
file, it shouldn't ask you / overwrite your custom values in the parameters.yml
file any more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With