Many times when working on a site, you are writing code and testing it locally first, before you even commit it to the development repository. Too often I've seen teams all share one sites/default/settings.php file, which leads to accidental commits which can halt everyone's development until the problem is resolved.
You can easily resolve this with 3 easy steps!
1. Create a local settings.php.
Whatever you named your site on your local server, create a sites/example_site/settings.php file. This is where all the settings go that will just apply to local dev environment. You're free to set your or database name, db user and password, or you can change php's error reporting level and available memory, and those are just some commonly useful adjustments. You can use the $config array to define some witewide variables, then you don't have to worry about changing things back whn you go to a new server (that server would have its own independent settings.php file).
2. Keep your local settings.php out of the code repository.
No one else wants it, its just for your desktop box. How do you do this? If you're using an IDE, most of them will let you add files or directories to svn:ignore. Poof! it will sit happily on your machine and be ignored - never to be committed accidentally. If you're just using the command line svn tool (may be different on a windows OS), use the more cryptic (cd to drupal root) svn propedit svn:ignore sites*, which will open a text editor for you. Add the line example_site (whatever you named your directory above), save and close. You should see the status message "Set new value for property 'svn:ignore' on 'sites'", and your new directory and the settings.php file within should be safely ignored.
3. Get rid of sites/default/settings.php!
Its tempting to keep this file around, and for smaller sites its probably ok. But when you move to large team development, and having more test environments (typically: local -> shared dev -> qa/stage -> prod), you don't want this dangerous fellow around. Your site should have basic configuration details for each of those servers, and you want to be sure what settings you are running. Its too easy to change a default settings.php "just to test something out", not realizing it may also be in use on other servers. You may not even find out until much later, when the code is actually deployed to a new server.
* If you havent set up a default shell editor, you may get an error message like "svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was found". This just means SVN didn't know where to find an editor to use. Instead try svn propedit --editor-cmd pico svn:ignore sites, and replace pico with your editor of choice. If you don't have an editor of choice, stick with pico and read the commands available at the bottom.




Latest Comments