<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Handling Multiple Environments In Your PHP Application</title>
	<atom:link href="http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/</link>
	<description>Facebook should&#039;ve be written in unicornSchemaLang, because everyone *knows* that PHP is no good for anything, right?</description>
	<lastBuildDate>Mon, 09 Aug 2010 16:04:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: CakePHP Digest Volume #3 :: PseudoCoder.com</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11090</link>
		<dc:creator>CakePHP Digest Volume #3 :: PseudoCoder.com</dc:creator>
		<pubDate>Tue, 16 Dec 2008 04:23:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11090</guid>
		<description>[...] There were also a couple interesting posts about handling environment specific settings in Cake apps. Personally I&#8217;m a fan of having a &#8220;boostrap.local.php&#8221; file that isn&#8217;t stored in SVN and is included in the normal bootsrap file. There&#8217;s no sex appeal to this method though, so if you don&#8217;t want to be standing alone in the corner while everyone else dances the night away, I suggest you read the posts by Neil Crookes and Chris Hartjes. [...]</description>
		<content:encoded><![CDATA[<p>[...] There were also a couple interesting posts about handling environment specific settings in Cake apps. Personally I&#8217;m a fan of having a &#8220;boostrap.local.php&#8221; file that isn&#8217;t stored in SVN and is included in the normal bootsrap file. There&#8217;s no sex appeal to this method though, so if you don&#8217;t want to be standing alone in the corner while everyone else dances the night away, I suggest you read the posts by Neil Crookes and Chris Hartjes. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Revue de presse &#124; Simple Entrepreneur</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11070</link>
		<dc:creator>Revue de presse &#124; Simple Entrepreneur</dc:creator>
		<pubDate>Thu, 04 Dec 2008 15:08:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11070</guid>
		<description>[...] Handling multiple environments in your PHP application Une approche originale pour détecter l&#8217;environnement (développement, staging, production,&#8230;) sur lequel une application est déployée et ainsi fournir des réglages spécifiques à cette plateforme. Qu&#8217;en pensez-vous ? [...]</description>
		<content:encoded><![CDATA[<p>[...] Handling multiple environments in your PHP application Une approche originale pour détecter l&#8217;environnement (développement, staging, production,&#8230;) sur lequel une application est déployée et ainsi fournir des réglages spécifiques à cette plateforme. Qu&#8217;en pensez-vous ? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: derek</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11049</link>
		<dc:creator>derek</dc:creator>
		<pubDate>Sat, 29 Nov 2008 14:19:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11049</guid>
		<description>I made a system that uses phing/ant to build a static config file for whatever environment/developer combo you want.

Each developer, and each system gets its own config file, which are kept under version control.

When you run the build script, you must tell it which system to build for, and you *can* tell it (optionally) which developer&#039;s config to use. The developer&#039;s config values override those of the environment, so that they can have their own paths etc.

Makes switching &#039;environments&#039; quick &amp; painless.</description>
		<content:encoded><![CDATA[<p>I made a system that uses phing/ant to build a static config file for whatever environment/developer combo you want.</p>
<p>Each developer, and each system gets its own config file, which are kept under version control.</p>
<p>When you run the build script, you must tell it which system to build for, and you *can* tell it (optionally) which developer&#8217;s config to use. The developer&#8217;s config values override those of the environment, so that they can have their own paths etc.</p>
<p>Makes switching &#8216;environments&#8217; quick &amp; painless.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jani Hartikainen</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11048</link>
		<dc:creator>Jani Hartikainen</dc:creator>
		<pubDate>Sat, 29 Nov 2008 12:34:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11048</guid>
		<description>This is a good tip, I&#039;ve used this approach several times with some Python apps and it works pretty nicely. Apache is full of useful small things :)</description>
		<content:encoded><![CDATA[<p>This is a good tip, I&#8217;ve used this approach several times with some Python apps and it works pretty nicely. Apache is full of useful small things <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes&#8217; Blog: Handling Multiple Environments In Your PHP Application : Dragonfly Networks</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11047</link>
		<dc:creator>Chris Hartjes&#8217; Blog: Handling Multiple Environments In Your PHP Application : Dragonfly Networks</dc:creator>
		<pubDate>Sat, 29 Nov 2008 11:21:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11047</guid>
		<description>[...] Hartjes has posted his method for creating a development setup that lets you use multiple environments with your [...]</description>
		<content:encoded><![CDATA[<p>[...] Hartjes has posted his method for creating a development setup that lets you use multiple environments with your [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11046</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Sat, 29 Nov 2008 10:39:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11046</guid>
		<description>Same solution, different aproach:
create a file `system.id` in every checkout which contains the environment set and just do a switch / case statement on the contents of that file... (and set the default of that switch to the dev-version)

That way the cli-version of the application will also have that environment variable set, it works in shared hosting setup&#039;s and it&#039;s real easy to implement :)
[code]
if (is_readable(dirname(__FILE__).&#039;/system.id&#039;)) define(&#039;SYSTEM_ID&#039;, trim(file_get_contents(dirname(__FILE__).&#039;/system.id&#039;)));
else define(&#039;SYSTEM_ID&#039;, SYSTEM_ID_DEV);
error_reporting(E_ALL);
switch ( SYSTEM_ID ) {
  case SYSTEM_ID_LIVE:
   error_reporting(E_NONE);
break;
etc etc</description>
		<content:encoded><![CDATA[<p>Same solution, different aproach:<br />
create a file `system.id` in every checkout which contains the environment set and just do a switch / case statement on the contents of that file&#8230; (and set the default of that switch to the dev-version)</p>
<p>That way the cli-version of the application will also have that environment variable set, it works in shared hosting setup&#8217;s and it&#8217;s real easy to implement <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
[code]<br />
if (is_readable(dirname(__FILE__).'/system.id')) define('SYSTEM_ID', trim(file_get_contents(dirname(__FILE__).'/system.id')));<br />
else define('SYSTEM_ID', SYSTEM_ID_DEV);<br />
error_reporting(E_ALL);<br />
switch ( SYSTEM_ID ) {<br />
  case SYSTEM_ID_LIVE:<br />
   error_reporting(E_NONE);<br />
break;<br />
etc etc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes&#8217; Blog: Handling Multiple Environments In Your PHP Application : WebNetiques</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11045</link>
		<dc:creator>Chris Hartjes&#8217; Blog: Handling Multiple Environments In Your PHP Application : WebNetiques</dc:creator>
		<pubDate>Sat, 29 Nov 2008 10:37:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11045</guid>
		<description>[...] Hartjes has posted his method for creating a development setup that lets you use multiple environments with your [...]</description>
		<content:encoded><![CDATA[<p>[...] Hartjes has posted his method for creating a development setup that lets you use multiple environments with your [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loïc Hoguin</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11041</link>
		<dc:creator>Loïc Hoguin</dc:creator>
		<pubDate>Fri, 28 Nov 2008 23:23:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11041</guid>
		<description>I use this: http://wee.extend.ws/wiki/ConfigurationFiles

There&#039;s only a few targets available but it could get improved easily by adding a custom target function or other useful targets, like yours.

So far it&#039;s been working perfectly using the host target, I just have to svn update on any of the dev/prod/test/.. servers/laptops/... and it&#039;s working. You can even use different configuration variables for different development environment if you wish. No &quot;multiple servers in a prod environment&quot; tested yet, but since the prod environment settings are the default ones in my files, that wouldn&#039;t be a problem.</description>
		<content:encoded><![CDATA[<p>I use this: <a href="http://wee.extend.ws/wiki/ConfigurationFiles" rel="nofollow">http://wee.extend.ws/wiki/ConfigurationFiles</a></p>
<p>There&#8217;s only a few targets available but it could get improved easily by adding a custom target function or other useful targets, like yours.</p>
<p>So far it&#8217;s been working perfectly using the host target, I just have to svn update on any of the dev/prod/test/.. servers/laptops/&#8230; and it&#8217;s working. You can even use different configuration variables for different development environment if you wish. No &#8220;multiple servers in a prod environment&#8221; tested yet, but since the prod environment settings are the default ones in my files, that wouldn&#8217;t be a problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hartjes</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11039</link>
		<dc:creator>Chris Hartjes</dc:creator>
		<pubDate>Fri, 28 Nov 2008 21:45:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11039</guid>
		<description>@Nasko

Interesting way of doing it, and probably better suited to a multi-developer environment than my method is.</description>
		<content:encoded><![CDATA[<p>@Nasko</p>
<p>Interesting way of doing it, and probably better suited to a multi-developer environment than my method is.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nasko</title>
		<link>http://www.littlehart.net/atthekeyboard/2008/11/28/handling-multiple-environments-in-your-php-application/comment-page-1/#comment-11038</link>
		<dc:creator>Nasko</dc:creator>
		<pubDate>Fri, 28 Nov 2008 21:36:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.littlehart.net/atthekeyboard/?p=343#comment-11038</guid>
		<description>What I do is branch the environment specific folders and files in the SVN and then just switch them in my working copy. This way I just don&#039;t bother to check what the current environment is in the code.

I&#039;d usually use the trunk for the production environment. This way a normal deployment script including an export from the trunk would operate on the production files only. 

Then I&#039;d create folders as branches in the SVN for each additional environment, e.g. dev, staging, etc. Normally I&#039;d name the environment folders after the hostnames the would be deployed on. This gives the additional benefit of having specific environment folders for different members of the development team, should they need to have specific settings, etc.

The resulting SVN structure would look something around this:


SVN
&#124;_trunk
&#124;_tags
&#124;_branches
   &#124;_environments
      &#124;_development
      &#124;  &#124;_app
      &#124;     &#124;_config
      &#124;     &#124;  &#124;_database.php
      &#124;     &#124;  &#124;_core.php
      &#124;     &#124;_webroot
      &#124;        &#124;_files  
      &#124;_staging
      &#124;  &#124;_app
      &#124;     &#124;_config
      &#124;     &#124;  &#124;_database.php
      &#124;     &#124;  &#124;_core.php
      &#124;     &#124;_webroot
      &#124;        &#124;_files  
      &#124;_john.dowe
         &#124;_app
            &#124;_config
            &#124;  &#124;_database.php
            &#124;  &#124;_core.php
            &#124;_webroot
               &#124;_files  


As soon as a new environment is needed, or an additional developer is added to the team, we create a corresponding folder under branches and add under it it just the environment-specific folders - like database settings and other configuration, plus a folder for any user-uploaded content. Then the new developer would checkout the trunk and in their working copy would switch just the env.-specific files - to the ones under their respective folder under branches/environments. 

This setup allows for both - having everything (environment specific configuration files, plus user-generated content, like uploaded files, etc.) under version control, and not overwriting each other&#039;s settings.

Then if someone needs to modify the configuration (e.g. add a new environment-specific setting, may be an SMTP server name), they can propagate the modification through to all other environment files, so all other members of the team would get it when they update their working copies.

For projects in which I&#039;m the only developer, I&#039;d just have folders for each environment. I normally don&#039;t care if my staging version is a working copy, so on the staging server I just checkout the trunk and switch only the staging-specific environment files. Then the normal working cycle wold be to work on development box, from time to time update the working copy on the staging environment and let the client preview the functionality, then finally export the trunk (which represents the production specific code) and upload it via SCP or FTP.

This might look as a slightly complicated setup to maintain, but once you&#039;re used to it it proves quite useful. At least for me. ;)</description>
		<content:encoded><![CDATA[<p>What I do is branch the environment specific folders and files in the SVN and then just switch them in my working copy. This way I just don&#8217;t bother to check what the current environment is in the code.</p>
<p>I&#8217;d usually use the trunk for the production environment. This way a normal deployment script including an export from the trunk would operate on the production files only. </p>
<p>Then I&#8217;d create folders as branches in the SVN for each additional environment, e.g. dev, staging, etc. Normally I&#8217;d name the environment folders after the hostnames the would be deployed on. This gives the additional benefit of having specific environment folders for different members of the development team, should they need to have specific settings, etc.</p>
<p>The resulting SVN structure would look something around this:</p>
<p>SVN<br />
|_trunk<br />
|_tags<br />
|_branches<br />
   |_environments<br />
      |_development<br />
      |  |_app<br />
      |     |_config<br />
      |     |  |_database.php<br />
      |     |  |_core.php<br />
      |     |_webroot<br />
      |        |_files<br />
      |_staging<br />
      |  |_app<br />
      |     |_config<br />
      |     |  |_database.php<br />
      |     |  |_core.php<br />
      |     |_webroot<br />
      |        |_files<br />
      |_john.dowe<br />
         |_app<br />
            |_config<br />
            |  |_database.php<br />
            |  |_core.php<br />
            |_webroot<br />
               |_files  </p>
<p>As soon as a new environment is needed, or an additional developer is added to the team, we create a corresponding folder under branches and add under it it just the environment-specific folders &#8211; like database settings and other configuration, plus a folder for any user-uploaded content. Then the new developer would checkout the trunk and in their working copy would switch just the env.-specific files &#8211; to the ones under their respective folder under branches/environments. </p>
<p>This setup allows for both &#8211; having everything (environment specific configuration files, plus user-generated content, like uploaded files, etc.) under version control, and not overwriting each other&#8217;s settings.</p>
<p>Then if someone needs to modify the configuration (e.g. add a new environment-specific setting, may be an SMTP server name), they can propagate the modification through to all other environment files, so all other members of the team would get it when they update their working copies.</p>
<p>For projects in which I&#8217;m the only developer, I&#8217;d just have folders for each environment. I normally don&#8217;t care if my staging version is a working copy, so on the staging server I just checkout the trunk and switch only the staging-specific environment files. Then the normal working cycle wold be to work on development box, from time to time update the working copy on the staging environment and let the client preview the functionality, then finally export the trunk (which represents the production specific code) and upload it via SCP or FTP.</p>
<p>This might look as a slightly complicated setup to maintain, but once you&#8217;re used to it it proves quite useful. At least for me. <img src='http://www.littlehart.net/atthekeyboard/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
