[thelist] An owed tip

Robert Gormley robert at pennyonthesidewalk.com
Tue Oct 4 20:46:57 CDT 2005


<tip type="Multiple site configuration" author="Robert Gormley>
So, a long time ago, I got frustrated with regularly forgetting to
change DB details, etc, path prefixes, whenever I uploaded from my
Windows laptop which I used for site development, to my production Unix
boxes.

Then I got the wise idea of 'switch'ing on the different environments,
in my case, delineated by HTTP_HOST_HEADER.

This was better, but still lead to a mass of repetitive constant
definitions, so finally I built an XML file which covered most of what I
saw fit:

<config>
	<site id="live">
		<name>Live</name>
		<environment id="devel">
			<name>Development</name>
			<database>
				<dbname>xx</dbname>
				...
			</database>
			<fsroot>/web/sites/blah.com</fsroot>

	...


And so on. Now, whilst I still have to do some parsing to determine
which site (in my case, laptop, live server) and environment (dev,
stage, prod)... It was much cleaner, and all of this information could
be pushed to another file outside the server tree (which in fairness, it
could have been anyway), and everything is much nicer.

And if anyone wants the source code to parse such a file (in PHP5, using
the SimpleXML extension), feel free to let me know off-list.
</tip>





More information about the thelist mailing list