Looking for a way to cleanly override the values of databases.yml in Doctrine / Symfony in order to use my own local settings?
The idea is not touching databases.yml and using some sort of local unversioned file to override that default.
I'm trying to find out how without much success yet :/
For this kind of configuration file, that contains stuff that depends on the environment (dev, testing, staging, production, ...), I generally use one file per environment, and all are commited to source-control.
For example, I could have :
databases.yml
== the development version, which will work when the project is checked out from source-control on a development computer.
databases.testing.yml
databases.staging.yml
databases.production.yml
Then, when building the .tag.gz
(or similar) archive that will be deployed to a different environment, I copy the file that corresponds to the destination's to the default one.
For example, when creating an archive that will be deployed on the production server, I copy databases.production.yml
to databases.yml
, in the archive.
This way, the application always uses databases.yml
, no matter what environment it's deployed on -- and all the possible configurations are commited to source-control.
Of course, this works much better if you are having some packaging / build process -- and don't just upload file to the servers via FTP by hand...
I generally add database.yml to svn:ignore and instead commit database.yml.sample.
The local will copy the database.yml.sample as database.yml and add their own values.
This way the database.yml file cannot be accidentally committed.