Subversion is a great way to update our web applications on our servers. With a simple svn update all changed files get… well, changed.
Except for the omnipresent configuration files such as config.php which hold the database access configuration, server paths etc. And are therefore different on my local development system and the remote server.
With the update command, a file modified on the server won’t get overwritten, but if I change the file locally and commit it, the server gets the wrong configuration file.
But I don’t want to set the svn:ignore property either, since the config file belongs to the project.
Is there a Subversion-mechanism which will allow me to easily handle these kind of files? Or is the only way to solve this problem to make a system switch within the config file which will determine the executing system and sets the configuration accordingly?
I find the easiest way is to switch on the machine’s hostname. I have a .ini file with a general section that also overrides this for production, testing and development systems.
So dev:db.password == ‘secret3’, but dev:db.host == ‘localhost’, from the original ‘general’ group.
The ‘production’, ‘testing’ and ‘dev’ could be the machine hostnames, or they are aliases for them set from some other mechanism in a configuration control script.