<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.h3rald.com/</id>
  <title>H3RALD - Tag 'tutorial' (Atom Feed)</title>
  <updated>2009-10-27T14:48:00Z</updated>
  <link href="http://www.h3rald.com" rel="alternate"/>
  <link href="http://www.h3rald.com/tags/tutorial/atom/" rel="self"/>
  <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 href="http://www.h3rald.com/articles/getting-started-with-lithium/" rel="alternate"/>
    <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="highlight"><pre>cgi_interp      php-cgi.exe
cgi_ext         php
</pre>
</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="highlight"><pre><span class="cp">&lt;?php</span>
<span class="nx">namespace</span> <span class="nx">app</span><span class="err">\</span><span class="nx">extensions</span><span class="err">\</span><span class="nx">action</span><span class="p">;</span>

<span class="k">class</span> <span class="nc">Request</span> <span class="k">extends</span> <span class="err">\</span><span class="nx">lithium</span><span class="err">\</span><span class="nx">action</span><span class="err">\</span><span class="nx">Request</span> <span class="p">{</span>

	<span class="k">protected</span> <span class="k">function</span> <span class="nf">_base</span><span class="p">()</span> <span class="p">{</span>
		<span class="k">return</span>  <span class="s1">&#39;?url=&#39;</span><span class="p">;</span>
	<span class="p">}</span>
<span class="p">}</span>
<span class="cp">?&gt;</span><span class="x"></span>
</pre>
</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,2006-07-14:/articles/cakephp-first-bite/</id>
    <title>The CakePHP Framework: Your First Bite</title>
    <published>2006-07-14T02:03:00Z</published>
    <updated>2009-09-06T18:10:54Z</updated>
    <link href="http://www.h3rald.com/articles/cakephp-first-bite/" rel="alternate"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="tutorial" scheme="http://www.h3rald.com/tags/tutorial/"/>
    <category term="review" scheme="http://www.h3rald.com/tags/review/"/>
    <content type="html">
<![CDATA[
<p>According to a recent study, <span class="caps">PHP</span> is one of the most popular programming languages in the world. In spite of this, <span class="caps">PHP</span> is often criticized for its inconsistent naming conventions, its lack of important features as compared to other languages (like namespaces) and its inherent disorganization. Furthermore, <span class="caps">PHP</span> is very easy to learn, and this has often led to the common misconception that most <span class="caps">PHP</span> developers are inexperienced and that their code is therefore prone to security vulnerabilities and exploits.<a href="http://www.sitepoint.com/article/application-development-cakephp">Read the full article</a> on <a href="http://www.sitepoint.com/">SitePoint.com</a></p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-07-07:/articles/ror-and-cakephp/</id>
    <title>Ruby on Rails &amp; CakePHP</title>
    <published>2006-07-07T07:52:28Z</published>
    <updated>2009-09-06T18:10:53Z</updated>
    <link href="http://www.h3rald.com/articles/ror-and-cakephp/" rel="alternate"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="rails" scheme="http://www.h3rald.com/tags/rails/"/>
    <category term="tutorial" scheme="http://www.h3rald.com/tags/tutorial/"/>
    <content type="html">
<![CDATA[
<p>This article is an attempt to port a famous Ruby on Rails tutorial to <span class="caps">PHP</span> using an emerging <span class="caps">PHP</span> <span class="caps">MVC</span> framework, CakePHP. CakePHP was inspired by Rails&#8217; philosophy of Rapid Application Development. It implements a lot of the features and concepts that made Ruby on Rails popular in a very short time. Although Ruby&#8217;s syntax and way of doing things is known to be much more elegant than other programming languages, there is yet hope for <span class="caps">PHP</span> to get more organized and effi cient. This tutorial will follow its Rails counterpart step-by-step, covering the essential steps to create a simple, yet fully functional, web application.<br />
Register on the <a href="http://www.php-mag.net/magphpde/psecom,id,20,archive,2,noeid,20,.html">International <span class="caps">PHP</span> Magazine</a> to read the full article.<br />
<img src="/img/thumbs/phpmag0706.gif" alt="" /></p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-05-30:/articles/cakephp-overview/</id>
    <title>An overview of the CakePHP framework</title>
    <published>2006-05-30T13:50:20Z</published>
    <updated>2009-09-06T18:10:52Z</updated>
    <link href="http://www.h3rald.com/articles/cakephp-overview/" rel="alternate"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="review" scheme="http://www.h3rald.com/tags/review/"/>
    <category term="tutorial" scheme="http://www.h3rald.com/tags/tutorial/"/>
    <content type="html">
<![CDATA[
<p><em>&#8220;There are many frameworks available for the <span class="caps">PHP</span> programming language nowadays, and especially a lot of <span class="caps">RAD</span> (Rapid Application Development) frameworks which aim to make web development faster, less tedious and more organized. CakePHP was one of the first frameworks to port the <span class="caps">RAD</span> philosophy &#8211; which became so popular after Ruby on Rails &#8211; to the <span class="caps">PHP</span> programming language. CakePHP v1.0 is now one of the most popular and intuitive solutions for <span class="caps">PHP</span> programming, let&#8217;s discover why&#8230;&#8221;</em></p>
<p><a href="http://hades.phparch.com/ceres/public/article/index.php/art::cakephp::overview">Read the full article</a> on <a href="http://hades.phparch.com/artemis/main/">php|architect article repository</a></p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-05-20:/articles/31/</id>
    <title>Watch out: CakePHP screencasts</title>
    <published>2006-05-20T13:47:00Z</published>
    <updated>2009-09-06T18:10:51Z</updated>
    <link href="http://www.h3rald.com/articles/31/" rel="alternate"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="tutorial" scheme="http://www.h3rald.com/tags/tutorial/"/>
    <content type="html">
<![CDATA[
<p>Tutorials are great, articles are helpful, manuals are essential and the <span class="caps">API</span> is your best friend, but there&#8217;s still something missing there&#8230; Unfortunately podcasts are not yet available, but the CakePHP team is proud to announce the creation of two <a href="http://cakephp.org/pages/screencasts">screencasts</a> in an effort to help new bakers familiarizing with CakePHP&#8217;s concepts. <br />
This is old news now, the screencasts section came together with the <a href="http://base--/blog/view/24">site overhaul</a> but I only got a chance to take a look at them (one of them only, to be totally honest) recently, and so here&#8217;s a spoil&#8230; erhm, a <em>detailed</em> description of John Anderson&#8217;s screencast about the <a href="http://manual.cakephp.org/chapter/18">Blog Tutorial</a>.</p>
<p style="float:left;"><img src="http://base--/img/pictures/CakePHP_1.0.png" alt="" /></p>
<p>There&#8217;s something I&#8217;ll never do: a screencast. Recording every mouse movement, every word or piece of code typed in half an hour? No way! And what happens if I mistype something? People will keep pointing out the fact that I was starting to type <code>&lt;/h2&gt;</code> to close a <code>&lt;/h1&gt;</code> tag, or that I waited an eternity like five full seconds before deciding what to do. I guess I&#8217;m quite paranoid&#8230; John did it, and he did it well. Using just bash, vim and Safari he was able to record an excellent 30-minutes screencast featuring the blog tutorial. <br />
Before people start complaining that the blog tutorial should be completed in fifteen minutes, keep in mind that John&#8217;s screencast is meant to show everything clearly to new users, via a trial and error approach if necessary.</p>
<p>Here&#8217;s what happens in the screencast, nothing new if your read the blog tutorial, but still interesting, especially if you&#8217;re new to Cake. Unfortunately there&#8217;s no audio, but the video talks by itself and John will occasionally write some comments here and there.</p>
<p><em><strong>0:01 &#8211; 5:00</strong></em></p>
<ul>
	<li><span class="caps">SVN</span> checkout to get the latest CakePHP version</li>
	<li>make app/tmp writeable</li>
	<li>execute queries (table posts)</li>
	<li>insert some test posts</li>
	<li>create database config file: modify 3 lines of database.php</li>
	<li>CakePHP is now able to connect to database</li>
	<li>create app/models/post.php model</li>
	<li>create posts_controller.php [John uses Vim as preferred <span class="caps">PHP</span> editor]</li>
	<li>try to access /posts/, error: missing method index()</li>
	<li>create function index() in postscontroller.php able to fetch posts</li>
	<li>refresh, missing index view</li>
	<li>create index.thtml displaying the raw posts array</li>
</ul>
<p><em><strong>5:01 &#8211; 10:00</strong></em></p>
<ul>
	<li>index.thtml: display posts with table and foreach iteration</li>
	<li>add hyperlink in index.thtml to view posts</li>
	<li>access /posts/view/1 &#8594; missing method view()</li>
	<li>add view() method in postscontroller.php</li>
	<li>create view.thtml to display</li>
	<li>Raw view post with pre tags and print_r()</li>
</ul>
<p><em><strong>10:01 &#8211; 15:00</strong></em></p>
<ul>
	<li>display post properly with <code>&lt;p&gt;</code> tags</li>
	<li>add link in index.thtml to add a post</li>
	<li>missing method &#8594; add()</li>
	<li>add add() in controller</li>
	<li>missing view [trial and error, trial and error&#8230;]</li>
	<li>create add.thtml, using the Html Helper to create input tags easily</li>
</ul>
<p><em><strong>15:01 &#8211; 20:00</strong></em></p>
<ul>
	<li>add.thtml (continued)</li>
	<li>testing add form</li>
	<li>view added post</li>
	<li>start adding another (for validation purposes) [stop before submitting]</li>
	<li>modify post.php model, valid_not_empty for title and body</li>
	<li>modify view to trigger validation <code>$html-&gt;tagErrorMsg()</code></li>
	<li>test: no body, message displayed</li>
	<li>test: no title, message displayed</li>
	<li>add another post, everything works</li>
	<li>[pause: five seconds]</li>
	<li>back to the controller, create delete() function</li>
</ul>
<p><em><strong>20:01 &#8211; 25:00</strong></em></p>
<ul>
	<li>delete function (continued)</li>
	<li>add &#8220;Actions&#8221; table column in index.thtml, with link delete post</li>
	<li>delete two posts</li>
	<li>take a breath</li>
	<li>add link in index.thtml to edit post</li>
	<li>refresh page, mouse over edit links&#8230;</li>
	<li>back to controller, add edit function [we learnt abour CakePHP errors alright]</li>
</ul>
<p><em><strong>25:01 &#8211; 27:38</strong></em></p>
<ul>
	<li>pause, 5 sec [should I write edit.thtml from scratch]</li>
	<li>copy add.thtml as edit.thtml</li>
	<li>change just the title and form action</li>
	<li>[pause: 3 sec]</li>
	<li>test edit link</li>
	<li>edit a post</li>
	<li>move around, switch views</li>
	<li>edit config/routes.php</li>
	<li>set default route to posts/index</li>
	<li>refresh &#8211;  all done!</li>
</ul>
<p>That&#8217;s it. All in a 40MB .mov file. Download it from <a href="http://www.archive.org/download/CakePHP_BlogTutorialJohn/BlogTutorial.mov">here</a>.</p>]]>
    </content>
  </entry>
</feed>
