[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Local vs Live Config for sites without root control

From: Ryan Schmidt <subversion-2006q2_at_ryandesign.com>
Date: 2006-06-29 23:57:59 CEST

On Jun 29, 2006, at 23:06, Tom Lancaster wrote:

> I'm sure this must have been discussed before, but I obviously
> haven't found the right keywords to search for.
>
> On one of my projects I am using separate config files for the web
> project which check what the name of the server is. I would like to
> know if it is possible to make a hook into svn to avoid having to
> do this.
>
> For example if I make a release, can that prompt a change in
> certain files while leaving the development copies the same?
>
> I only ask because I would rather not have my live code constantly
> checking what server it is running on.

I do this in my sites:

<?php
if (LIVE_SERVER) {
        define('DB_HOST', 'dbserver');
        define('DB_USER', 'foo');
        define('DB_PASS', 'bar');
} else {
        define('DB_HOST', 'localhost');
        define('DB_USER', 'root');
        define('DB_PASS', '');
}
?>

And the LIVE_SERVER constant is defined to true only on the
development server.

If you wanted to avoid such a check, one alternative would be this way:

http://subversion.tigris.org/faq.html#ignore-commit

The PHP code could be:

require_once('config.local.php');

where config.local.php is a file that's not in your repository (in
fact you'd probably add it to the svn:ignore list of the directory
it's in) but must be configured in each working copy. Though I think
checking whether a constant is true or false would be faster than
reading in a whole 'nother file.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Jun 29 23:59:13 2006

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.