<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.h3rald.com/</id>
  <title>H3RALD - Tag 'li3' (Atom Feed)</title>
  <updated>2009-10-27T14:48:00Z</updated>
  <link rel="alternate" href="http://www.h3rald.com"/>
  <link rel="self" href="http://www.h3rald.com/tags/li3/atom/"/>
  <author>
    <name>Fabio Cevasco</name>
    <uri>http://www.h3rald.com</uri>
  </author>
  <entry>
    <id>tag:www.h3rald.com,2009-10-27:/articles/getting-started-with-lithium/</id>
    <title>Getting Started with Lithium</title>
    <published>2009-10-27T14:48:00Z</published>
    <updated>2009-10-29T10:50:12Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/getting-started-with-lithium/"/>
    <category term="li3" scheme="http://www.h3rald.com/tags/li3/"/>
    <category term="php" scheme="http://www.h3rald.com/tags/php/"/>
    <category term="tutorial" scheme="http://www.h3rald.com/tags/tutorial/"/>
    <content type="html">
<![CDATA[
<p>So <a href="http://li3.rad-dev.org/">Lithium</a> is now officially out, and its 0.1 release can be freely <a href="http://rad-dev.org/lithium/versions">downloaded</a> from the official web site or by cloning the Lithium git repository. The good news is that although not many web hosts offer <span class="caps">PHP</span> 5.3, you can try it out youself, locally and with minimum effort.</p>
<h3>Requirements</h3>
<p>According to the <a href="http://rad-dev.org/wiki/guides/setup">Lithium Wiki</a>, to develop applications with Lithium you need:</p>
<ul>
	<li>A web server, like Apache or <span class="caps">IIS</span></li>
	<li><span class="caps">PHP</span> 5.3.0 or higher</li>
	<li>Git (not required, but all example projects are on git repos, so you may as well have it)</li>
</ul>
<p>For this tutorial, more specifically, you need to download (just download, don&#8217;t install anything!):</p>
<ul>
	<li><a href="http://code.google.com/p/mongoose/">mongoose</a>, a tiny, standalone (as <em>in one single file</em>), cross-platform web server.</li>
	<li><a href="http://www.php.net/downloads.php#v5"><span class="caps">PHP</span> 5.3.0</a>, not the installer, the zip package.</li>
	<li><a href="http://rad-dev.org/lithium/versions">Lithium</a> (version 0.1, at the time of writing)</li>
	<li>The <a href="http://rad-dev.org/li3_docs">li3_docs plugin</a>.</li>
</ul>
<p>To get the li3_docs plugin you need to <a href="http://rad-dev.org/users/add">register</a> on rad-dev.org, and clone the li3_docs git repository. If you don&#8217;t have git installed or you don&#8217;t want to read <a href="http://spheredev.org/wiki/Git_for_the_lazy">another awesome tutorial</a> to install it and learn how to use it, I&#8217;ll save you the hassle and let you download the plugin from <a href="/files/li3_docs.zip">here</a>, for this time ony.</p>
<p><b>Note:</b> This tutorial assumes that you are on Windows. If you are not, some things may be a bit different depending on your platform.</p>
<h3>Setting up the environment</h3>
<p>Choose a directory on your sistem (let&#8217;s call it <b>D:\lithium_test</b> from now on). We&#8217;ll do everything in here, and you can move it anywhere you like afterwards, even on a <span class="caps">USB</span> stick, without breaking anything.</p>
<ol>
	<li>Unzip Lithium in <b>D:\lithium_test</b>, so that it contains the following files and directories:
	<ul>
		<li>app/</li>
		<li>libraries/</li>
		<li>.htaccess (it won&#8217;t actually be used in this tutorial)</li>
	</ul></li>
	<li>Unzip <span class="caps">PHP</span> 5.3.0 somewhere and copy the following files to the <b>D:\lithium_test</b> folder:
	<ul>
		<li>php5.dll</li>
		<li>php-cgi.exe</li>
		<li>php.ini (just get php.ini-development from the <span class="caps">PHP</span> package and rename it)</li>
	</ul></li>
	<li>Copy the mongoose-2.8.exe executable in <b>D:\lithium_test</b> and rename it to <b>mongoose.exe</b> for convenience.</li>
	<li>Create a <b>mongoose.conf</b> file containing the following lines:</li>
</ol>
<div class="CodeRay">
  <div class="code"><pre><span class="line-numbers"><a href="#n1" name="n1">1</a></span>cgi_interp      php-cgi.exe
<span class="line-numbers"><a href="#n2" name="n2">2</a></span>cgi_ext         php
</pre></div>
</div>

<p>If you did everything correctly, your <b>D:\lithium_test</b> directory should contain the following:</p>
<ul>
	<li>app\</li>
	<li>libraries\</li>
	<li>.htaccess</li>
	<li>mongoose.exe</li>
	<li>mongoose.conf</li>
	<li>php-cgi.exe</li>
	<li>php.ini</li>
	<li>php5.dll</li>
</ul>
<h3>Running Lithium</h3>
<p>Double click <b>mongoose.exe</b> and point your browser of choice to <a href="http://localhost:8080/app/webroot/index.php">http://localhost:8080/app/webroot/index.php</a>. You should see the Lithium temporary homepage (yes, I expected something fancier too):</p>
<p><img src="/img/pictures/lithium/temp_homepage.png" alt="" /></p>
<p>Now, let&#8217;s see if we can get the li3_docs plugin running as well:</p>
<ol>
	<li>Unzip <b>li3_docs.zip</b> and copy the <b>li3_docs</b> folder in <b>D:\lithium_test\app\libraries\plugins</b>.</li>
	<li>Open <b>D:\lithium_test\app\config\bootstrap.php</b> and add the line: <code>Libraries::add('plugin', 'li3_docs');</code> at the end. I actually found this commented out already (line 80).</li>
</ol>
<p>Go to <a href="http://localhost:8080/app/webroot/index.php?url=docs">http://localhost:8080/app/webroot/index.php?url=docs</a>, you should see something like this:</p>
<p><img src="/img/pictures/lithium/li3_docs.png" alt="" /></p>
<p>Congratulation, you&#8217;re now running your first Lithium application!</p>
<h3>Fixing URLs</h3>
<p>Once the initial excitement wears off you&#8217;ll notice that none of the links on the docs page works.</p>
<p>That&#8217;s because the mongoose web server does not support <span class="caps">URL</span> rewriting (and Lithium needs it badly right now), so we have to change the way URLs are created. <a href="http://twitter.com/nateabele">@nateabele</a> gave me <a href="http://pastium.org/view/3a966c1446fcbd1d4f5a94d882256987">some tips</a> on how to do this; it&#8217;s very simple:</p>
<ol>
	<li>Create a directory called <b>action</b> in <b>D:\lithium_test\app\extensions</b>.</li>
	<li>Create a file called <b>Request.php</b>, containing the following:</li>
</ol>
<div class="CodeRay">
  <div class="code"><pre><span class="line-numbers"> <a href="#n1" name="n1">1</a></span><span class="inline-delimiter">&lt;?php</span>
<span class="line-numbers"> <a href="#n2" name="n2">2</a></span><span class="keyword">namespace</span> app\extensions\action;
<span class="line-numbers"> <a href="#n3" name="n3">3</a></span>
<span class="line-numbers"> <a href="#n4" name="n4">4</a></span><span class="keyword">class</span> <span class="class">Request</span> <span class="keyword">extends</span> \lithium\action\<span class="constant">Request</span> {
<span class="line-numbers"> <a href="#n5" name="n5">5</a></span>
<span class="line-numbers"> <a href="#n6" name="n6">6</a></span>  <span class="keyword">protected</span> <span class="keyword">function</span> <span class="function">_base</span>() {
<span class="line-numbers"> <a href="#n7" name="n7">7</a></span>    <span class="keyword">return</span>  <span class="string"><span class="delimiter">'</span><span class="content">?url=</span><span class="delimiter">'</span></span>;
<span class="line-numbers"> <a href="#n8" name="n8">8</a></span>  }
<span class="line-numbers"> <a href="#n9" name="n9">9</a></span>}
<span class="line-numbers"><strong><a href="#n10" name="n10">10</a></strong></span><span class="inline-delimiter">?&gt;</span>
</pre></div>
</div>

<p>We&#8217;re basically extending the <code>\lithium\action\Request</code> with a custom class, telling Lithium how to create the base <span class="caps">URL</span>.</p>
<p>After doing so, open <b>D:\lithium_test\app\webroot\index.php</b> and change:</p>
<p><code>echo lithium\action\Dispatcher::run();</code></p>
<p>into:</p>
<code>echo lithium\action\Dispatcher::run(new app\extensions\action\Request());</code>
<p>In this case, we&#8217;re instructing the dispatcher to use our custom Request class instead of the default one.</p>
<p>Now everything should work as expected. Reload the docs page (<a href="http://localhost:8080/app/webroot/index.php?url=docs">http://localhost:8080/app/webroot/index.php?url=docs</a>) and verify that the links work by navigating to <code>Lithium</code>, then <code>action</code> and finally <code>Controller</code>.</p>
<p>Now you can use Lithium to display its own <span class="caps">API</span> locally (if things didn&#8217;t work out, there&#8217;s always <a href="http://li3.rad-dev.org/docs">http://li3.rad-dev.org/docs</a>).</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2009-10-24:/articles/too-many-cooks-take-3/</id>
    <title>Too many cooks... take #3</title>
    <published>2009-10-24T18:26:59Z</published>
    <updated>2009-10-24T19:34:22Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/too-many-cooks-take-3/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="rant" scheme="http://www.h3rald.com/tags/rant/"/>
    <category term="php" scheme="http://www.h3rald.com/tags/php/"/>
    <category term="li3" scheme="http://www.h3rald.com/tags/li3/"/>
    <content type="html">
<![CDATA[
<p>Like <a href="http://www.h3rald.com/articles/too-many-cooks-take-2/">its predecessor</a>, this is another rant about the (end of the) <a href="http://www.cakephp.org">CakePHP framework</a>. Not that I particularly enjoy writing about the misfortune of others, but after reading <a href="http://bakery.cakephp.org/articles/view/the-cake-is-still-rising">this official announcement</a> I felt compelled to post.</p>
<p>It has been two years since my last post on this subject and yes, the cake is still rising, but at what price? Will it still taste sweet now that two of its main ingredients are not part of it anymore? As <a href="http://cakebaker.42dh.com/2009/10/23/the-end-of-cakephp/">Daniel</a> puts it, <em>probably the best thing to do now is to drink tea and to wait until the dust settles&#8230;</em></p>
<p>As far as I&#8217;m concerned, what really matters is that Garrett Woodworth (former CakePHP Project Manager) and Nate Abele (former CakePHP Lead Developer) are <em>gone</em>. They realized they had enough Nuts over the years and they decided to switch to a more <a href="http://irc.cakephp.org/logs/link/1110092#message1110102">Lithium-rich</a> diet. More helthy and depression-proof, too!</p>
<p>Stupid metaphors and painful jokes aside, this is probably the best piece of news the CakePHP community received in a long time: the birth of <em>a fork of the CakePHP framework</em>, more precisely of the so-called Cake3 branch.</p>
<p><em>Cake3</em>? I didn&#8217;t keep up-to-date with the buzz, so I didn&#8217;t know anything about this until today, when I decided to finally start catching up.</p>
<blockquote>
<p>&#8220;Cake 3.0, on the other hand, is pretty different from the existing core code in a few notable ways. Mainly, it&#8217;s been re-written from the ground up for <span class="caps">PHP</span> 5.3.&#8221;</p>
</blockquote>
<p style="padding-right:6em;">from <a href="http://debuggable.com/posts/Cake_3_interview_with_Nate_Abele:4a665a5e-5bfc-4e42-96ee-6d284834cda3">Cake 3 interview with Nate Abele</a>, debuggable.com</p>
<p>Of course, in these three years of my full immersion in the Ruby language, I almost completely forgot about <span class="caps">PHP</span> too. <span class="caps">PHP</span> 5.3 means namespace and closures, i.e. the Rubyist&#8217;s daily bread. A more modular CakePHP, properly object-oriented, with an ActiveRecord-like <span class="caps">API</span> for models (finally!) is definitely worth a look, especially if it&#8217;s Nut-free as well.</p>
<p>The new framework will be called <strong>Lithium</strong> (sounds more professional already), and it&#8217;s due to launch next monday, here: <a href="http://li3.rad-dev.org/">http://li3.rad-dev.org/</a> (at the time of writing, this link is password-protected).</p>
<p>Personally, I am <em>very</em> excited about this new project. It should have happened three years ago, really, but there&#8217;s no point in being greedy: the time has finally come. I would like to (pre-)thank Garrett and Nate for their (upcoming) amazing work, I&#8217;ll definitely keep a closer eye on it.</p>]]>
    </content>
  </entry>
</feed>

