<?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>laneolson.ca &#187; Best Practices</title>
	<atom:link href="http://www.laneolson.ca/tag/best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.laneolson.ca</link>
	<description></description>
	<lastBuildDate>Fri, 07 Jan 2011 23:06:53 +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>Share Your CakePHP Core and Application Files Server Wide</title>
		<link>http://www.laneolson.ca/2008/12/10/share-your-cakephp-core-server-wide/</link>
		<comments>http://www.laneolson.ca/2008/12/10/share-your-cakephp-core-server-wide/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 23:52:41 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[code reuse]]></category>

		<guid isPermaLink="false">http://laneolson.wordpress.com/?p=15</guid>
		<description><![CDATA[If you are deploying several Cake applications server wide you may want to keep the Cake core in one central place so that it can be easily updated.  In order to do this place the cake core directory somewhere on your server where is can be accessed.  For example /usr/lib/php/cake.  Then, when you create your applications open up your root index file  and replace the following:

1
2
3
if &#40;!defined&#40;'CAKE_CORE_INCLUDE_PATH'&#41;&#41; &#123;
	define&#40;'CAKE_CORE_INCLUDE_PATH', ROOT&#41;;
&#125;

with this:

1
2
3
if &#40;!defined&#40;'CAKE_CORE_INCLUDE_PATH'&#41;&#41; &#123;
	define&#40;'CAKE_CORE_INCLUDE_PATH', DS . 'usr' . DS . 'lib' . DS . 'php' . DS . 'cake'&#41;;
&#125;

You are now using the common cake core.  When a new update comes out to the library, just replace the files in /usr/lib/php/cake with the new version!
If you want to go a step further and share some of your own models, views, controllers, behaviors, helpers, or components between applications you can use a similar technique.  For example create a folder in &#8216;/usr/lib/php/models&#8217; and put all your common models in that folder, then in your application open up bootstrap.php and add the following:

1
2
3
$modelPaths = array&#40;
DS . 'usr' . DS . 'lib' . DS . 'php' . DS . 'models'
&#41;;

Like I said the same thing can be done with views, controllers, helpers, behaviors or components.  The cookbook says how!  This is pretty handy for when you find a bug in a model and you have several applications using that model!

]]></description>
			<content:encoded><![CDATA[<p>If you are deploying several Cake applications server wide you may want to keep the Cake core in one central place so that it can be easily updated.  In order to do this place the cake core directory somewhere on your server where is can be accessed.  For example /usr/lib/php/cake.  Then, when you create your applications open up your root index file  and replace the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CAKE_CORE_INCLUDE_PATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CAKE_CORE_INCLUDE_PATH'</span><span style="color: #339933;">,</span> ROOT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>with this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CAKE_CORE_INCLUDE_PATH'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'CAKE_CORE_INCLUDE_PATH'</span><span style="color: #339933;">,</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'usr'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'lib'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'php'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'cake'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You are now using the common cake core.  When a new update comes out to the library, just replace the files in /usr/lib/php/cake with the new version!</p>
<p>If you want to go a step further and share some of your own models, views, controllers, behaviors, helpers, or components between applications you can use a similar technique.  For example create a folder in &#8216;/usr/lib/php/models&#8217; and put all your common models in that folder, then in your application open up bootstrap.php and add the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$modelPaths</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'usr'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'lib'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'php'</span> <span style="color: #339933;">.</span> DS <span style="color: #339933;">.</span> <span style="color: #0000ff;">'models'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><span class="keyword">Like I said the same thing can be done with views, controllers, helpers, behaviors or components.  The <a href="http://book.cakephp.org/view/36/Additional-Class-Paths">cookbook says how</a>!  This is pretty handy for when you find a bug in a model and you have several applications using that model!<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.laneolson.ca/2008/12/10/share-your-cakephp-core-server-wide/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

