<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>leftcolumn.net &#187; config</title>
	<atom:link href="http://www.leftcolumn.net/tags/config/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.leftcolumn.net</link>
	<description>Covering Mac OS X, Mac Software, and other stuff</description>
	<lastBuildDate>Tue, 11 May 2010 12:51:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Zend Framework one-line platform config: Configure, Don&#8217;t Integrate</title>
		<link>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/</link>
		<comments>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 04:06:22 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[zend framework]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.leftcolumn.net/?p=146</guid>
		<description><![CDATA[Separating config from code in Zend Framework is not as simple as it is in say, Ruby on Rails. And when your source code is version-controlled you want to minimise the manual configuration required. So here&#8217;s a nice way to keep it simple. The idea is to keep configuration data for your test and production [...]]]></description>
			<content:encoded><![CDATA[<p>Separating config from code in <a href="http://framework.zend.com/">Zend Framework</a> is not as simple as it is in say, <a href="http://rubyonrails.org/">Ruby on Rails</a>. And when your source code is version-controlled you want to minimise the manual configuration required. So here&#8217;s a nice way to keep it simple. The idea is to keep configuration data for your test and production environments in a single config file that does not change, then switch environments in a dedicated separate one-line config file.</p>
<p>Here&#8217;s a sample platforms.ini:</p>
<pre>
[test]
developer_mode = true
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.dbname = testdb
db.params.username = lkdf034k3k3b
db.params.password = SJGS43we3sdd

[production]
developer_mode = false
db.adapter = PDO_MYSQL
db.params.host = localhost
db.params.dbname = productiondb
db.params.username = ksjdhfkjjdhf
db.params.password = jfdhkjsdhdjk</pre>
<p>.. .And here&#8217;s active_platform.ini. This is where we define which of test or production is currently active:</p>
<pre>[platform]
setting = test</pre>
<p>&#8230;And here&#8217;s how index.php refers to active_platform.ini to first determine which platform it&#8217;s on, and second load the appropriate config from platforms.ini:</p>
<pre>// which platform mode are we on? i.e.: test or production
$active_platform = new Zend_Config_Ini('application/configs/active_platform.ini','active_platform');

// get the platform config
$config = new Zend_Config_Ini('application/configs/platforms.ini', $active_platform->setting);
Zend_Registry::set('config', $config);

// set up the db
$db = Zend_Db::factory($platform_config->db);
Zend_Db_Table::setDefaultAdapter($db);</pre>
<p>When you want to deploy to production, you change the setting in active_platform.ini to &#8216;production.&#8217; Simple as that.. this may be obvious but I&#8217;ve found it to speed up deployment and make it less error-prone. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.leftcolumn.net/2009/02/18/zend-framework-one-line-platform-config-configure-dont-integrate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
