<?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>Geekality &#187; Kohana</title>
	<atom:link href="http://www.geekality.net/tag/kohana/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekality.net</link>
	<description>With a hint of Social Ineptitude</description>
	<lastBuildDate>Sun, 05 Feb 2012 17:53:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP: One way of differing between DEV and PROD environments with Kohana</title>
		<link>http://www.geekality.net/2012/01/12/php-one-way-of-differing-between-dev-and-prod-environments-with-kohana/</link>
		<comments>http://www.geekality.net/2012/01/12/php-one-way-of-differing-between-dev-and-prod-environments-with-kohana/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 22:22:49 +0000</pubDate>
		<dc:creator>Torleif</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Environment]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Setup]]></category>

		<guid isPermaLink="false">http://www.geekality.net/?p=1904</guid>
		<description><![CDATA[Usually when I develop websites, they will be deployed to a domain, for example www.geekality.net. But when I develop this site locally, I usually want it to be in some sub-folder of localhost, since I usually have more than one &#8230; <a href="http://www.geekality.net/2012/01/12/php-one-way-of-differing-between-dev-and-prod-environments-with-kohana/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Usually when I develop websites, they will be deployed to a domain, for example www.geekality.net. But when I develop this site locally, I usually want it to be in some sub-folder of localhost, since I usually have more than one website going on, and I don&#8217;t want the trouble with virtual-hosts. So, to solve this for my Kohana websites I do the following simple thing. This technique would work for other websites programmed in PHP as well, but the PHP part would probably be a bit different.</p>
<p><span id="more-1904"></span></p>
<h2>Apache httpd.conf</h2>
<p>First of all, I add this to the end of my httpd.conf.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"># Custom htaccess file<br />
AccessFileName .htaccess.local .htaccess</div></div>
<p>Make sure to check if there is already a line with AccessFileName though, and if it is, just edit that instead of adding another one <img src='http://www.geekality.net/wp-includes/images/blank.gif' alt=':)' class='wp-smiley smiley-1' /> </p>
<h2>Environment variables</h2>
<p>With that done, you can have one regular .htaccess which would be used in production and a local one for your machine.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#.htaccess<br />
SetEnv KOHANA_ENV production<br />
SetEnv KOHANA_BASE /<br />
RewriteBase /</div></div>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">#.htaccess.local<br />
SetEnv KOHANA_ENV development<br />
SetEnv KOHANA_BASE /geekality/<br />
RewriteBase /geekality/</div></div>
<p>These two files can now live side by side, checked in to source control, and not cause any trouble. Alternatively you could set the local one to be ignored so that other developers could create their own setup.</p>
<h2>Kohana bootstrap</h2>
<p>Now comes the Kohana specific part. In my application/bootstrap.php I have the following (among other stuff of course).</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'KOHANA_ENV'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; Kohana<span style="color: #339933;">::</span><span style="color: #000088;">$environment</span> <span style="color: #339933;">=</span> <span style="color: #990000;">constant</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Kohana::'</span><span style="color: #339933;">.</span><span style="color: #990000;">strtoupper</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'KOHANA_ENV'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
Kohana<span style="color: #339933;">::</span><span style="color: #004000;">init</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><br />
&nbsp; <span style="color: #0000ff;">'base_url'</span> &nbsp; <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'KOHANA_BASE'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #0000ff;">'index_file'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #0000ff;">'profile'</span> <span style="color: #339933;">=&gt;</span> Kohana<span style="color: #339933;">::</span><span style="color: #000088;">$environment</span> <span style="color: #339933;">!==</span> Kohana<span style="color: #339933;">::</span><span style="color: #004000;">PRODUCTION</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #0000ff;">'caching'</span> <span style="color: #339933;">=&gt;</span> Kohana<span style="color: #339933;">::</span><span style="color: #000088;">$environment</span> <span style="color: #339933;">!==</span> Kohana<span style="color: #339933;">::</span><span style="color: #004000;">DEVELOPMENT</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #0000ff;">'errors'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>And that&#8217;s pretty much all there is to it. This way I don&#8217;t have to worry about not overwriting the .htaccess on my production server or stuff like that. The .htaccess is untouched and just for the production environment <img src='http://www.geekality.net/wp-includes/images/blank.gif' alt=':)' class='wp-smiley smiley-1' /> </p>
<p class="wp-flattr-button"></p> <p><a href="http://www.geekality.net/?flattrss_redirect&amp;id=1904&amp;md5=0e58ab261f2f2ee24146da7ab4c4b525" title="Flattr" target="_blank"><img src="http://www.geekality.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.geekality.net/2012/01/12/php-one-way-of-differing-between-dev-and-prod-environments-with-kohana/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Kohana PHP framework</title>
		<link>http://www.geekality.net/2010/04/19/kohana-php-framework/</link>
		<comments>http://www.geekality.net/2010/04/19/kohana-php-framework/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 19:59:46 +0000</pubDate>
		<dc:creator>Torleif</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Kohana]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.geekality.net/?p=956</guid>
		<description><![CDATA[As you might know, I am developing some internal software for LifeStyleTV at the moment. Because of various slightly annoying circumstances I am stuck using PHP and MySQL for this. Not the worst of course, but I must say I &#8230; <a href="http://www.geekality.net/2010/04/19/kohana-php-framework/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><div id="attachment_965" class="wp-caption alignright" style="width: 210px"><img src="http://www.geekality.net/wp-content/uploads/2010/04/Construction-200x300.jpg" alt="" title="Construction" width="200" height="300" class="size-medium wp-image-965" /><p class="wp-caption-text">sxc.hu</p></div>As you might know, I am developing some internal software for LifeStyleTV at the moment. Because of various slightly annoying circumstances I am stuck using PHP and MySQL for this. Not the worst of course, but I must say I really do prefer C# over PHP for oh so many reasons. But anyways, that wasn&#8217;t the point of this post. The point is that for my life to become hopefully quite a bit easier and hopefully a lot more organized I decided to go looking for a framework I can use as a base for the software I will be developing.</p>
<p>After much looking I finally stumbled over a framework called <a href="http://kohanaframework.org">Kohana</a>. </p>
<p><span id="more-956"></span></p>
<blockquote><p>Kohana is an open source, <a href="http://wikipedia.org/wiki/Object-Oriented_Programming">object oriented</a> <a href="http://techportal.ibuildings.com/2010/02/22/scaling-web-applications-with-hmvc/">H</a> <a href="http://en.wikipedia.org/wiki/Model_view_controller" title="Model View Controller">MVC</a> <a href="http://wikipedia.org/wiki/Web_Framework">web framework</a> built using <a href="http://php.net/manual/intro-whatis" title="PHP Hypertext Preprocessor">PHP5</a> by a team of volunteers that aims to be swift, secure, and small.</p>
<p>Kohana is licensed under a <a href="http://kohanaframework.org/license">BSD license</a>, so you can legally use it for any kind of open source, commercial, or personal project.</p></blockquote>
<p>Getting started with it was a bit of a hassle because the documentation isn&#8217;t the greatest, but the small community has been helpful and the framework is pretty clear once you grasp the basics. For me it was particularly difficult since I don&#8217;t really have that much experience with MVC frameworks at all. But so far it has been very fun to learn and code with it.</p>
<p>There are currently <a href="http://kerkness.ca/kowiki/doku.php?id=what_version_of_kohana_should_i_use">two versions of Kohana</a>, 2 and 3. These are pretty much different frameworks, and I decided to go for version 3 as it seem to be cleaner and support HMVC which <a href="http://techportal.ibuildings.com/2010/02/22/scaling-web-applications-with-hmvc/">seems very interesting</a>.</p>
<p>Here are some very helpful resources that helped me get started:</p>
<ul>
<li><a href="http://dev.kohanaphp.com/projects/kohana3/files">Latest version of Kohana 3</a></li>
<li><a href="http://kerkness.ca/kowiki">The Unofficial Kohana 3.0 Wiki</a></li>
<li><a href="http://kohanaframework.org/3.2/guide/">Kohana userguide</a></li>
<li><a href="http://www.dealtaker.com/blog/tag/ko3/">Kohana 3 tutorial</a> at <a href="http://www.dealtaker.com/blog/">Inside DealTaker</a></li>
<li><a href="http://kohana.sher.pl/cs/">Kohana 3 CheatSheet</a></li>
<li>The Kohana <a href="irc://irc.freenode.net/kohana">irc channel</a></li>
</ul>
<p>Alrighty, will blog more about Kohana some other day. Maybe even some tutorials&#8230;? </p>
<p>Are you using any PHP frameworks? What do you use? Please share!</p>
<p class="wp-flattr-button"></p> <p><a href="http://www.geekality.net/?flattrss_redirect&amp;id=956&amp;md5=43d2d0412bab7fa7b2c035da6001cecc" title="Flattr" target="_blank"><img src="http://www.geekality.net/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.geekality.net/2010/04/19/kohana-php-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

