<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <id>http://www.h3rald.com/</id>
  <title>H3RALD - Tag 'webdevelopment' (Atom Feed)</title>
  <updated>2010-09-23T12:04:25Z</updated>
  <link rel="alternate" href="http://www.h3rald.com"/>
  <link rel="self" href="http://www.h3rald.com/tags/webdevelopment/atom/"/>
  <author>
    <name>Fabio Cevasco</name>
    <uri>http://www.h3rald.com</uri>
  </author>
  <entry>
    <id>tag:www.h3rald.com,2010-09-23:/articles/h3rald-81/</id>
    <title>H3RALD.com v8.1 Released</title>
    <published>2010-09-23T12:04:25Z</published>
    <updated>2010-09-24T11:50:21Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/h3rald-81/"/>
    <category term="website" scheme="http://www.h3rald.com/tags/website/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[

		<section class="section">
<p>Just <a href="/articles/take-back-your-site-with-nanoc">over a year ago</a> I released the 8th version of this web site. The biggest change then was abandoning the Rails-powered <a href="http://wiki.github.com/fdv/typo/">Typo</a> blogging platform in favor of <a href="http://nanoc.stoneship.org/">nanoc</a>, arguably the most versatile static site generator out there.</p>
<p>A year later, I am still very happy with nanoc, hence there&#8217;s no need for another major release. Nonetheless, I decided to improve the site&#8217;s overall design and image, making it (hopefully) easier to use and more pleasant to the eye.</p>
<p>I always had a problem finding the right theme for my web site. I always wanted to find something related to the word <em>herald</em>, so in the last release I went for a herandry-oriented theme. For this release, I decided to go for a newspaper-style layout: after all, the word <em>herald</em> is often used in newspaper titles, and I picked the name &#8220;h3rald&#8221; after the <a href="http://global.nytimes.com/?iht">International Herald Tribune</a>.</p>
<p>Also, I was desperate to try out the new features offered by HTML5 and CSS3, and a newspaper layout seemed a good excuse to use columns.</p>
<section class="section">
<header><h1 id="h_1">Browser Compatibility</h1></header>
<p>Although I shouldn&#8217;t really say this, the site is meant to be viewed with a WebKit-based browser, really. It works in other (modern) browsers (read: no IE6), and it degrades more or less gracefully if a particular feature is not supported.</p>
<p>That being said:</p>
<ul>
	<li>IE7 and IE8 just barely render it (Javascript is used to &#8220;patch&#8221; the <span class="caps">DOM</span> with the new HTML5 elements)</li>
	<li>Firefox 3+ renders pretty much everything right.</li>
	<li>Safari and Chrome render the site as it is actually meant to be rendered</li>
</ul>
<p>Nobody ever died from not being able to see CSS3 rounded corners anyhow. The most important thing about this site is its content, and I made sure that whatever browser you&#8217;re using you can still read it.</p>

</section>
<section class="section">
<header><h1 id="h_2">Columns and hyphenation</h1></header>
<p>As I previously stated, I couldn&#8217;t wait to try out CSS3 columns so I kinda went crazy on the home page, but just there. Some may argue that they are not suitable for web use of course, but I think they contribute to give the site layout a unique feeling.</p>
<p>The problem with having columns is of course text alignment: justified text looks good, but unless you hyphenate text properly it shows a lot of blank space. Luckily, I discovered <a href="http://code.google.com/p/hyphenator/">hyphenator.js</a>, which solved the problem nicely.</p>

</section>
<section class="section">
<header><h1 id="h_3">CSS and layout improvements</h1></header>
<p>I made a point out of improving the old stylesheet to make the site easier to read and generally prettier. Beauty is in the eye of the beholder, but still, I think the new stylesheet brings some improvements, especially concerning text (the <a href="http://scripts.sil.org/gentium">Gentium</a> font is used throughout the site) and syntax highlighting.</p>
<p>Moreover, I worked on streamlining navigations across different sections of the site, in particular on article pages:</p>
<p><img src="/img/pictures/h3rald_81_article.png" alt="" /></p>

</section>
<section class="section">
<header><h1 id="h_4">Under the hood</h1></header>
<p>Besides appearence, the new site also features some improvements in its underlying business logic. In particular:</p>
<ul>
	<li>Better nanoc <a href="http://github.com/h3rald/h3rald/blob/master/Rules">Rules</a></li>
	<li>Improved <a href="/glyph/">Glyph</a> integration, by extending nanoc <a href="http://github.com/h3rald/h3rald/blob/master/lib/glyph_context.rb">RuleContext</a></li>
	<li>Minor updates to the custom <a href="http://github.com/h3rald/h3rald/blob/master/tasks/site.rake">Rake tasks</a></li>
	<li><a href="http://disqus.com/overview/">Disqus</a> comments</li>
</ul>

</section>

</section>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-08-01:/articles/38/</id>
    <title>Akelos is real, after all...</title>
    <published>2006-08-01T23:33:00Z</published>
    <updated>2009-09-06T18:10:54Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/38/"/>
    <category term="frameworks" scheme="http://www.h3rald.com/tags/frameworks/"/>
    <category term="php" scheme="http://www.h3rald.com/tags/php/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <category term="review" scheme="http://www.h3rald.com/tags/review/"/>
    <content type="html">
<![CDATA[
<p>Bermi Ferrer kept his promise, and even if a few were skeptic on the <a href="http://base--/blog/view/34/">pre-announced</a> features of his upcoming Akelos framework, last week he sent me a &#8220;development preview&#8221; and a few days ago he opened the development <span class="caps">SVN</span> repository to the public:</p>
<p><a href="svn://akelos.org/trunk" target="_blank">svn://akelos.org/trunk</a></p>
<p>Go, get it: it&#8217;s worthwhile (see below).</p>
<p>&#8220;[&#8230;] The Akelos Framework is an open-source port of Ruby on Rails to the <span class="caps">PHP</span> programming language.<br />
The main goal of the Akelos Framework is to help programmers to build multilingual database-backed web applications according to the Model-View-Control pattern. It lets you write less code by favoring conventions over configuration.&#8221;</p>
<p>At the Akelos Framework Features page you can find detailed information about what has been already implemented into the framework.</p>
</blockquote>
<p>I think it says it all, well almost. Some people will undoubtedly be disgusted by yet-another-hopeless-Rails-clone: <em>not again!</em> I hear them crying&#8230;</p>
<p>Well, yeah, I think this &#8211; to be honest &#8211; should be the last attempt someone makes to port Rails to <span class="caps">PHP</span> or at least port <em>some features and the overall philosophy</em>, like <a href="http://base--/bookmarks/view/cakephp">CakePHP</a> did: there are honestly too many for one single language. Look at Python, <a href="http://www.djangoproject.com/">Django</a> seems to be the only &#8220;Rails-inspired&#8221; framework available and everyone is happy with it, while as a general rule <span class="caps">PHP</span> folks are never happy with what they already got.</p>
<p>Bermi is undoubtedly one of them, and that&#8217;s the reason he decided to code his very own Rails-inspired framework for <span class="caps">PHP</span>, which is, to date, the most remarkable of the ones I left out (it wasn&#8217;t available at the time) in my <a href="http://base--/articles/rails-inspired-php-frameworks/">article</a>.</p>
<h3>Confirmed Features &amp; Contents</h3>
<p>So well, although I didn&#8217;t really have a proper chance to play with Akelos I can certainly herald some of its &#8211; verified, this time &#8211; features.</p>
<p>For one, it&#8217;s huge. Take Cake, add <em>every excellent, useful third party library or class you can possibly thing of</em> and you&#8217;ll get Akelos. No kidding. The unzipped source of the whole framework is a massive 16MB, 8.5 of which constitute the <code>vendors</code> folder. What&#8217;s in it? Well, all this:</p>
<ul>
	<li>ADOdb</li>
	<li>Domit</li>
	<li><span class="caps">FPDF</span></li>
	<li>Excel (reader library)</li>
	<li>Hyper Estraier full-text search system</li>
	<li>Inutio <span class="caps">XML</span>-<span class="caps">RPC</span> Library</li>
	<li><em>Many</em> <span class="caps">PEAR</span> packages</li>
	<li>PHPCodeAnalyzer</li>
	<li>PHPmailer</li>
	<li>SimpleTest</li>
	<li>A Simple <span class="caps">PHP</span> <span class="caps">YAML</span> Class</li>
	<li>Textile</li>
</ul>
<p>Then, similarly, all the state-of-the-art Javascript/<span class="caps">AJAX</span> hyper-hyped libraries are included:</p>
<ul>
	<li><span class="caps">AFLAX</span></li>
	<li>Behaviour</li>
	<li>Builder</li>
	<li>various Scriptaculous packages</li>
	<li>Prototype</li>
	<li>FileUploader (by the author, using prototype)</li>
	<li>Window</li>
	<li>EventSelectors</li>
</ul>
<p style="float:left;"><img src="http://base--/img/pictures/frameworks/akelos_framework_logo.gif" alt="" /></p>
<p>Good, well, kind of: that&#8217;s just what <em>others</em> did, but it&#8217;s worth noting that it&#8217;s all there and &#8211; apparently &#8211; integrated with the framework, hopefully not too tightly. But people are fussy, and do not get excited easily anymore, long gone are the early days of Rails, when the whole Internet shake at hearing about <em>code generators</em>&#8230; Aye, there are in Akelos as well, of course!</p>
<p>Coming to the more juicy stuff, <em>lo&#8217; and behold, ye contents of /lib folder (with comments):</em></p>
<ul>
	<li>AkActionController (controller)</li>
	<li>AkActionView (view)</li>
	<li>AkActionWebservice (Web services)</li>
	<li>AkActiveRecord (model)</li>
	<li>AkAdodbCache (content caching)</li>
	<li>AkCharset (utf8 support, includes <em>all</em> mappings)</li>
	<li>AkConfig (load config settings)</li>
	<li>AkConverters (conversions!)
	<ul>
		<li>DBDesigner &gt; AkelosDatabaseDesign</li>
		<li>Excel &gt; Array (bi-dimensional)</li>
		<li>Excel &gt; <span class="caps">CSV</span></li>
		<li><span class="caps">HTML</span> &gt; <span class="caps">RTF</span></li>
		<li><span class="caps">HTML</span> &gt; Text</li>
		<li>Word &gt; Unicode</li>
		<li><span class="caps">PDF</span> &gt; Text</li>
		<li>Xdoc &gt; Text</li>
	</ul></li>
	<li>AkHeaders (<span class="caps">HTTP</span> headers, redirections)</li>
	<li>AkImages (Image operations, resizing)</li>
	<li>AkLocalize (Localization, countries and timezones)</li>
	<li>AkInflector</li>
	<li>AkLogger</li>
	<li>AkFtp</li>
	<li>AkInstaller</li>
	<li>AkRouter</li>
	<li>AkZip</li>
	<li>&#8230;</li>
</ul>
<p>Well, it&#8217;s all there, at any rate. The best way to know if it all works, and <em>how</em> it works, is simply to try it out: <a href="http://www.akelos.org/">www.akelos.org</a>.</p>
<h3>Remarks</h3>
<p>As I said earlier, Akelos looks like <em>CakePHP on steroids</em>: agreed, the Cake philosophy of &#8220;no we-may-use-it code in the trunk&#8221; has been <em>completely</em> (and intentionally) ignored, but this is our chance to peek at what CakePHP could have become if such philosophy didn&#8217;t become a lifestyle for the Cake Dev Team. <br />
Akelos code is Rails-inspired, so yes, it&#8217;s <em>very</em> similar to Cake, although with some rough edges and some re-used parts, but it&#8217;s the work of <span class="caps">ONE</span> person with no community support (yet), don&#8217;t forget. Remarkable.</p>
<p>And he needs co-developers, by the looks of it, so there you are then: there&#8217;s <em>your</em> chance!</p>
<p>My personal opinion about it? Well, I think Akelos can learn from CakePHP and vice-versa: a merge? Well, at least it would reduce the number of Rails-inspired framework for <span class="caps">PHP</span> and <em>possibly</em> meet the needs of more people: those who want just the essentials, as a framework, and those who like to be <em>virtually almighty</em> and be able to do anything, <em>if they wanted to</em>.</p>
<p>Two flavours of the same framework? <em>CakePHP</em> and <em>cAkePHP</em> (note the case)? Bah, let&#8217;s stop raving now, shall we?</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-05-02:/articles/24/</id>
    <title>CakePHP 1.0 released</title>
    <published>2006-05-03T03:06:00Z</published>
    <updated>2009-09-06T18:10:53Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/24/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[
<p>As <a href="http://digg.com/programming/CakePHP_1.0_has_been_released">Digg</a>_ points out, the first <em>stable</em> version of CakePHP was released, yesterday. I should have posted yesterday about it, and no, I didn&#8217;t forget: I was just busy downloading the new version, have a look at the new site, talk to people etc.</p>
<p>Anyhow, it&#8217;s ready, just baked and smells damn good. Go get it if you didn&#8217;t already, it&#8217;s available at <a href="http://cakeforge.org/frs/?group_id=23">the usual place</a>, even this time you won&#8217;t be disappointed. CakePHP now reached the 1.0 milestone, in a way which reminds me a lot about Mozilla Firefox: a lot of people were already using it <em>before</em> it went stable officially!</p>
<p style="float:left;"><img src="http://base--/img/pictures/CakePHP_1.0.png" alt="" /></p>
<p>The CakePHP Team has been humble enough not to declare their product <em>stable</em> before the time. I personally considered CakePHP stable <em>enough</em> since RC2&#8230; and considering that this site and many others have been built on alpha, beta and RC version, I think people can get an idea of Cake&#8217;s reliability.<br />
Nothing (too) new came out the oven this time: CakePHP 1.0 is mainly a bugfix release, with all the features we&#8217;ve learnt to love. It&#8217;s just <em>better_: a lot of things have been fixed, model associations work better, etc. etc. You can read the <a href="http://cakeforge.org/frs/shownotes.php?group_id=23&amp;release">changelog/announcement</a></em>id=85 or have a look below for a quick summary of the new features and most interesting fixes:</p>
<pre><code>
Revision: [2420]
Added fix for Ticket #320.
Fixed Model::save() so it will only allow a model to save itself.
Fixed Model::save() when saving a HABTM association

Revision: [2437]
Adding fix for Model::findNeighbours().
Was returning all associations and fields. Now recursive
is set to 0 and only returns the prev and next keys array

Revision: [2456]
"Enables use of Controller::$data in addition to Controller::$params['data']"

Revision: [2490]
Fixing a bug that occurs when connecting to two different
databases on the same server, and enabling cross-database
model associations

Revision: [2491]
Adding Microsoft SQL Server driver [EXPERIMENTAL]

Revision: [2577]
Adding $alias property to enable future Oracle support

Revision: [2625]
Bringing all DB drivers up to date

Revision: [2653]
Adding check for custom error class in app/.
Added check for AppController::appError(); will be called if this method 
is in AppController.
</code></pre>
<p style="float:right;"><img src="http://base--/img/pictures/cakesite.png" alt="" /></p>
<p>If you&#8217;re not too excited about this new release, maybe you should have a look at <a href="http://www.cakephp.org">www.cakephp.org</a>. Different? Damn right it is: it looks like someone listened to our prayers for a new website design. The merciful soul is <a href="http://www.nolimit-studio.com/">Armando Sosa</a>, the winner of CakePHP&#8217;s design contest. He&#8217;s a latin-american web designer who had the <span class="caps">GREAT</span> idea of thinking about an <em>innovative</em> design for the Cake site&#8230; Actually my dad didn&#8217;t think that way: <em>&#8220;That&#8217;s not new, that way of advertising was all over the place when I was a kid!&#8221;</em> And he&#8217;s right, Armando thought that a fifties-like template would have been perfect for Cake. Forget all the smooth, roundy-and-chubby, toons-like &#8220;official&#8221; Web 2.0 designs (beta), the new Cake site needs to stand out of the crowd&#8230;</p>
<p style="float:left;"><img src="http://base--/img/pictures/fonz.jpg" alt="" /></p>
<p><br /><br />
<em>Heyyy! Well done guys&#8230;</em></p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-04-29:/articles/22/</id>
    <title>Ten minutes on Rails (while eating Cake)</title>
    <published>2006-04-29T13:29:00Z</published>
    <updated>2009-09-06T18:10:52Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/22/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="rails" scheme="http://www.h3rald.com/tags/rails/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[
<p>Today I decided to do something different, something I&#8217;ve been dying to do since before coming across CakePHP: give Rails a <em>proper</em> try. Like many other <span class="caps">PHP</span> developers out there, when <a href="http://www.rubyonrails.org">Ruby on Rails</a> came out I felt damn jealous and terribly tempted to learn Ruby <em>only</em> to start using such an amazing web development framework. At the time I actually even started reading various tutorials about it, and I was literally amazed at how RoR revolutioned the way of developing web applications.</p>
<p style="float:left;"><img src="http://base--/img/pictures/rails.gif" alt="" /></p>
<p>One of the main problems which made me &#8211; sadly &#8211; abandon Rails was Ruby itself: personally I&#8217;ve never seen a programming language with a cleaner and more elegant syntax, but also &#8211; at least at the time &#8211; there weren&#8217;t many hosts supporting it. LuckilyI found CakePHP quickly after that&#8230;<br />
Now however, more and more hosting companies boast full Rails support, and so when recently I <a href="http://base--/blog/view/21/">had to move</a> to a new host, I made sure it was Rails-friendly, <em>just in case I wanted to give Rails another try, someday</em>.<br />
Oh well, the temptation was so strong that today, only a two days after switching to my new host, I felt I <em>had</em> to try it, I <em>had</em> to taste something different than the usual Cake.</p>
<p>I decided to (re-)read and follow the <a href="http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html">OnLamp tutorial</a> about RoR, step by step, once again. I quickly typed <code>rails cookbook</code> from my shell and voil&aacute;, rails silently creates the skeleton of my application:</p>
<p><span class="caps">README</span><br />
Rakefile<br />
app/<br />
components/<br />
config/<br />
db/<br />
doc/<br />
favicon.ico<br />
index.html<br />
lib/<br />
log/<br />
public/<br />
script/<br />
structure.txt<br />
test/<br />
tmp/<br />
vendor/</p>
<p>That&#8217;s familiar: it&#8217;s very similar to what CakePHP&#8217;s directory structure used to look like. Now Cake <em>evolved</em> and adopted its own schema, which &#8211; I must say &#8211; seems more functional than RoR&#8217;s, at least at a first glance:</p>
<ul>
	<li>app/
	<ul>
		<li>config/</li>
		<li>controllers/</li>
		<li>models/</li>
		<li>plugins/</li>
		<li>tmp/</li>
		<li>vendors/</li>
		<li>views/</li>
		<li>webroot/</li>
	</ul></li>
	<li>cake/
	<ul>
		<li>config/</li>
		<li>docs/</li>
		<li>libs/</li>
	</ul></li>
	<li>vendors/</li>
</ul>
<p style="float:right;"><img src="http://base--/img/pictures/cakephp.png" alt="" /></p>
<p>Cake felt the necessity to divide what you can mess with (<code>app/</code>, <code>vendors/</code>) from what you&#8217;d better not touch (<code>cake/</code>). Rails just left everything on the same level.</p>
<p>After creating my database and the necessary tables I have to edit <code>config/database.yml</code>, which corresponds to Cake&#8217;s <code>app/config/database.php</code>. Then things start to become a bit different from Cake, as Rails offers some very handy built in scripts which can be used to automatically create your application&#8217;s files, i.e. executing <code>ruby script/generate controller Recipe</code> creates the controller and other bits:</p>
<pre><code>exists  app/controllers/
exists  app/helpers/
create  app/views/recipe
exists  test/functional/
create  app/controllers/recipe_controller.rb
create  test/functional/recipe_controller_test.rb
create  app/helpers/recipe_helper.rb</code></pre>
<p>And so on. Anyhow&#8230; I followed the tutorial and yes, it was a nice read. CakePHP borrowed a lot from Rails but not everything. Inevitably Ruby&#8217;s syntax is less verbose and looks very very clean:</p>
<p>&lt;% highlight :ruby do %&gt;<br />
class RecipeController &lt; ApplicationController<br />
	scaffold :recipe</p>
<p>def list<br />
		@recipes = Recipe.find_all<br />
	end</p>
<p>def edit<br />
		<code>recipe = Recipe.find(</code>params[&#8220;id&#8221;])<br />
		@categories = Category.find_all<br />
	end<br />
end<br />
&lt;% end %&gt;</p>
<p>While CakePHP&#8217;s, simply because it uses <span class="caps">PHP</span> and not Ruby, looks less pretty:</p>
<p>&lt;% highlight :php do %&gt;<br />
class RecipesController extends AppController<br />
{<br />
	var $scaffold;</p>
<p>function list()<br />
	{<br />
		$this&#8594;set(&#8216;recipes&#8217;, $this&#8594;Recipe&#8594;findAll());<br />
	}</p>
<p>function edit($id)<br />
	{<br />
		$this&#8594;set(&#8216;recipe&#8217;, $this&#8594;Recipe&#8594;find(&#8220;id = $id&#8221;));<br />
		$this&#8594;set(&#8216;categories&#8217;, $this&#8594;Category&#8594;findAll());<br />
	}</p>
<p>}<br />
&lt;% end %&gt;</p>
<p>CakePHP Development Team did a great job translating some of Rails functionalities into <span class="caps">PHP</span>, and the while CakePHP&#8217;s syntax is <strong>much</strong> cleaner if compared to PHP&#8217;s standard spaghetti-code approach, Ruby just looks much more clear, sorry. <em>Imagine a world without funny unnecessary brackets, pointless semicolons and where everything just looks better</em>: that&#8217;s Ruby.</p>
<p>Sigh. Now I do understand why Rails was built in Ruby and not in <span class="caps">PHP</span>: simply because a PHP&#8217;s Rails would have been outscored by its &#8220;Ruby port&#8221;!</p>
<p>One thing I liked about Rails which has not been ported in Cake (yet) is a somehow smarter way of scaffolding. While the Ruby code above actually works, the CakePHP&#8217;s edit method doesn&#8217;t, or better, it does but not as expected: when you remove <code>var $scaffold</code> the scaffold is just plain gone, and you have to code everything yourself, while in Ruby you can leave the scaffold and then develop methods one by one, and still be able to use scaffolded methods if you didn&#8217;t define the custom ones.</p>
<p>The other thing I noticed about RoR is that it definitely handles errors better! This is probably another language issue. I basically forgot to set a category for the recipes, and when executing my custom list of recipes I got a very, very well structured error page showing something like:</p>
<p>&lt;% highlight :ruby do %&gt;<br />
NoMethodError in Recipe#index</p>
<p>Showing app/views/recipe/index.rhtml where line #18 raised:</p>
<p>You have a nil object when you didn&#8217;t expect it!<br />
The error occured while evaluating nil.name</p>
<p>Extracted source (around line #18):</p>
<p>15:  &lt;% @recipes.each do |recipe| <span>&gt;<br />
16:   <tr><br />
17:    <td>&lt;</span>= link_to recipe.title, :action =&gt; &#8220;show&#8221;, :id =&gt; recipe.id <span>&gt;</td><br />
18:    <td>&lt;</span>= recipe.category.name <span>&gt;</td><br />
19:    <td>&lt;</span>= recipe.date <span>&gt;</td><br />
20:   </tr><br />
21:  &lt;</span> end <span>&gt;<br />
&lt;</span> end %&gt;</p>
<p>I took a screenshot of the page, because it was too nice: <a href="http://base--/img/pictures/rails_error.jpg">check it out</a>. This error page really tells you what&#8217;s wrong, and even prints the lines of code around the error! It also lets the developer check the full backtrace and every sort of information&#8230; Can we have this in CakePHP please? I actually started to develop something like this, but seemed quite hard to do in <span class="caps">PHP</span>.</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-04-16:/articles/16/</id>
    <title>Databases supported by CakePHP</title>
    <published>2006-04-17T05:30:00Z</published>
    <updated>2009-09-06T18:10:51Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/16/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <category term="databases" scheme="http://www.h3rald.com/tags/databases/"/>
    <content type="html">
<![CDATA[
<p>One of the most recurring questions on CakePHP User Group is probably <em>&#8220;Does Cake support X database?&#8221;</em>. Sure, most of us tend to use just MySQL for our websites and applications, but in certain situations some more <em>exotic</em> database support makes the difference. A partial answer to the question above could be <em>&#8220;Yes, probably, at least partially&#8221;</em>: CakePHP offers support for some database &#8220;natively&#8221; (i.e. Cake folks made some <em>ad hoc</em> database drivers), others through either <a href="http://adodb.sourceforge.net/">ADOdb</a> or <a href="http://pear.php.net/package/DB"><span class="caps">PEAR</span>::DB</a>.</p>
<p>CakePHP seems to use a <em>multiple level</em> database abstraction: in other words, popular abstraction layers like ADOdb or <span class="caps">PEAR</span>::DB have been wrapped in a &#8220;driver&#8221; which basically extends the DboSource class (which is the most high level database abstraction). Some people don&#8217;t like the idea, because this means that the could be some performance issues, for one, and also that inevitably not <em>all</em> features offered by either ADOdb or <span class="caps">PEAR</span>::DB are used. In my very, very, very modest opinion (I&#8217;m not an expert on this matter), this solution focus on achieving good database compatibility leaving the doors open for further tinkering, if needed.</p>
<p style="float:left;"><img src="http://base--/img/pictures/postgres.png" alt="" /></p>
<p>Having said this, yes, the possibilities are good that your favorite database is supported by CakePHP, more or less. Of course, as repeatedly pointed out by some CakePHP core developers, Cake dev team didn&#8217;t and is not going to test <em>every</em> database with Cake, using either of the two abstraction layers, but users are more than welcome to do so.</p>
<p>Let&#8217;s now have a look at what is <em>known to work</em> with Cake:</p>
<p><strong>MySQL</strong> works fine, and is currently recommended as <em>preferred</em> database solution. What about <strong>MySQLi</strong>? Well, thanks to mappleJoe there&#8217;s a (PHP5 only!) <a href="http://cakephp.org/pastes/show/770e73e77e4d7a3d32c2f3de3f175512">driver</a> ready to be used.</p>
*PostgreSQL*&#8217;s support is continuously improving. Something may work, something may not: the good news is that the folks who are using it are <a href="http://groups.google.com/group/cake-php/browse_thread/thread/85a29ab6ec6826a0/8eecea26ba53e1fd?q=postgres&amp;rnum=1#8eecea26ba53e1fd">sharing their thoughts</a> with the rest of us.
<p style="float:right;"><img src="http://base--/img/pictures/sqlite.gif" alt="" /></p>
<p><strong>SQLite</strong> is supported natively, or so it seems&#8230; what about the newest SQLite3? Yes, probably: there&#8217;s a quick <a href="http://www.thompsonlife.net/index.php?section=9">howto</a> on ThompsonLife.net to make it work through the dbo_pear driver.</p>
<p><strong>Access</strong> works through the ADOdb driver, as reported in CakePHP <a href="http://wiki.cakephp.org/docs:databases">wiki</a> (thanks ivanp).</p>
<p><a href="http://www.filemaker.com/">FileMaker</a> is getting there: things aren&#8217;t that easy, but bdb is doing <a href="http://groups.google.com/group/cake-php/browse_thread/thread/572d8dd2ba4cbdf7/dca851c795247c0b?q=database&amp;rnum=2#dca851c795247c0b">all his best</a> to make it work, good luck!</p>
<p>Neil Fincham was also trying to develop a custom driver to support <a href="http://www.pervasive.com/">Pervasive</a> through a <a href="http://www.unixodbc.org/">unixODBC</a> driver. Best of luck!</p>
<p>For other databases, check ADOdb&#8217;s <a href="http://phplens.com/adodb/supported.databases.html">list of supported databases</a> and use the <code>dbo-adodb</code> driver, or use <span class="caps">PEAR</span>::DB (for fbsql, ibase, informix, msql, mssql, mysql, mysqli, oci8, odbc, pgsql,sqlite and sybase) using the <code>dbo-pear</code> driver.</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-04-15:/articles/15/</id>
    <title>I18n</title>
    <published>2006-04-15T13:15:00Z</published>
    <updated>2009-09-06T18:10:50Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/15/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[
<p><em>&#8220;CakePHP will officially support Internationalization (i18n) from version 2.0&#8221;</em>. That is to say: not right now. That doesn&#8217;t mean we have to wait, no chance! I&#8217;m Italian and there are plenty of bakers speaking a language other than English who might want to develop a multi-lingual website.</p>
<p>I did, <a href="http://v60.h3rald.com/">once</a>, and the final result wasn&#8217;t too bad in the end: every page of the site (except the articles) could be translated into Italian. Before examining my solution (which is far from optimal) I&#8217;d like to mention an excellent CakePHP package which allows basic (mostly statuc) i18n.<br />
It looks like I missed an important baker in my recent <a href="http://base--/blog/view/11">blog post</a>: <a href="http://www.noswad.me.uk/">Andy Dawson</a>, creator &#8211; among other things &#8211; of the <a href="http://cakeforge.org/snippet/detail.php?type=package&amp;id=2">Locale Package</a>, available at CakeForge. His solution actually came out after H3RALD.com v60 was already developed so I didn&#8217;t use it for my own site.<br />
At a first glance Andy&#8217;s solution truly solves basic l18n problems in an elegant way: the most important code snippet is the <a href="http://cakeforge.org/snippet/download.php?type=snippet&amp;id=74">Locale Component</a> which provides the following functionalities:</p>
<ul>
	<li>automatic language detection based on browser&#8217;s UserAgent string</li>
	<li>loading of locale files</li>
	<li>setting of customizeable (translated) messages</li>
</ul>
<p>The getString() method provided in the locale component is actually used through the double underscore function, which is already defined (but not yet implemented) in the standard CakePHP file <code>cake/basics.php</code> (yes, this is a small core hack). Andy&#8217;s double underscore function can take five parameters:</p>
<pre><code>function __($msgId, $MessageArgs=NULL, $capitalize=1, $punctuate=0,$Code=NULL)
{
    require_once(COMPONENTS.'locale.php');
    $Locale = LocaleComponent::getInstance();
    return $Locale-&gt;getString( $msgId, $MessageArgs, $capitalize, $punctuate, $Code );
}</code></pre>
<p>These parameters are:</p>
<ul>
	<li>a &#8220;message id&#8221; or the message itself</li>
	<li>some parameters which can be passed to the message</li>
	<li>the message&#8217;s capitalization:
	<ul>
		<li>0 = no change</li>
		<li>1 = first letter of first word</li>
		<li>2 = fist character of all words</li>
	</ul></li>
	<li>the message&#8217;s punctuation:
	<ul>
		<li>0 = &quot;&quot;</li>
		<li>1 = .</li>
		<li>2 = !</li>
		<li>3 = ?</li>
	</ul></li>
	<li>the language code, if you need to override your page&#8217;s language</li>
</ul>
<p>This is a convenient method which can be used everywhere, both in your controllers and in your views, to translate simple pre-stored messages. Where are those messages stored? In various locale files which must be placed in <code>app/controllers/components/messages/</code> and look like this:</p>
<pre><code>   $messages = Array (
    'LocaleSetTo'=&gt;"Site locale set to UK English",
    'LocaleChangeTo'=&gt;"Change site locale to UK English",
    // Time related messages
    'ago' =&gt; "%s ago",
    'ages' =&gt; "a long time ago (%s)",
)</code></pre>
<p>The locale package also comes with a <em>Language Controller</em> you can use to handle language changes, and a useful rewrite of the <em>Time Helper_. Andy recently updated his <a href="http://wiki.cakephp.org/tutorials:i18n">i18n tutorial</a> available on CakePHP Wiki, a very interesting read on how to quickly add i18n support to yout first Cake blog (yes, the one described in the <a href="http://wiki.cakephp.org/tutorials:blog_tutorial">Blog Tutorial</a>_-</em>1).</p>
<p>So far so good. The Locale Package provide some basic multi-lingual support in an efficient way, and I&#8217;d certainly use it if I decide to (re-)develop a multi-lingual site, but unfortunately this does not fully solve the problem.<br />
If you want <strong>full</strong> i18n, for sure you&#8217;d like to have all the contents of your website translated, which is &#8211; normally &#8211; dynamic and maybe stored in a database. That was the case of my old website: all the pages are dynamic, not static, so I had to think about something else. <br />
Since I only had plans to develop a <em>dual</em> language site, I opted for a very lazy (but yet effective) solution: each table &#8211; more or less &#8211; had &#8220;duplicate&#8221; fields, something like this:</p>
<ul>
	<li>id</li>
	<li>title_en</li>
	<li>title_it</li>
	<li>text_en</li>
	<li>text_it</li>
	<li>created</li>
	<li>modified</li>
</ul>
<p>I basically defined a global $lang variable set to &#8220;en&#8221; by default and then I accessed the record&#8217;s fields (for example in views) like this:</p>
<p><code>echo $data['Project']['text_'.$lang]</code></p>
<p>Ugly, perhaps, but did the job. The good (or bad) thing about this technique was that I could modify the contents of a project, for example, regardless of the current language: in my add/edit view, I chose to generate <em>all</em> the fields of a table and therefore modify all the fields of a project without switching to the other language.</p>
<p>How will Cake support locales? Will we have &#8220;localized&#8221; database tables (and models?) Only time will tell&#8230;</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-04-14:/articles/14/</id>
    <title>CakePHP hybrids</title>
    <published>2006-04-14T07:55:00Z</published>
    <updated>2009-09-06T18:10:49Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/14/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <category term="php" scheme="http://www.h3rald.com/tags/php/"/>
    <content type="html">
<![CDATA[
<p>When I first talked to gwoo, CakePHP&#8217;s project manager, I asked him if Cake had any potential <em>limitations</em>. I asked him &#8211; I was kidding actually &#8211; wether it would be possible to build an application like Gmail using the framework and he &#8211; very seriously &#8211; simply said <em>&#8220;yes, why not?&#8221;</em>. <br />
I repeat myself when I say that CakePHP leaves plenty of freedom to developers within the bounds of its <span class="caps">MVC</span> structure: once you grasp the basic logic behind it, your possibilities are endless. I don&#8217;t want to act as a Ruby on Rails fanatic and boast that <em>you can do anything  with CakePHP</em> and things like that, but I can certainly say that CakePHP can be <em>extended</em> and <em>integrated</em> with other collections of scripts, frameworks and projects. With limitations, of course: you probably don&#8217;t want to force an integration between CakePHP and another <span class="caps">MVC</span>/Event Driven/Whatever framework, simply because it would be rather pointless and potential conflicts may occur.</p>
<p>What I keep finding online is other open source projects adopting CakePHP as <em>backend</em> and <em>structure</em>. I&#8217;m sure there are many examples which could be mentioned here, but I chose two in particular: one has been around for a few months and the other is just born.</p>
<p style="float:left;"><img src="http://base--/img/pictures/amfphp.jpg" alt="" /></p>
<p><a href="http://amfphp.org/"><span class="caps">AMFPHP</span></a> is quite an interesting project:</p>
<blockquote>
<p>&#8220;[it] is an open-source Flash Remoting gateway. It&#8217;s fast, reliable, 100% free and open-source. Flash Remoting is a technology built into the Flash player core that enables sending data between the server and the client seemlessly.&#8221;</p>
</blockquote>
<p>In other words, it makes lifes much easier for developers who&#8217;d like to integrate their flash animations and script more tightly into their <span class="caps">PHP</span> application. If you are curious to see some results, head off to <span class="caps">AMFPHP</span> <a href="http://amfphp.org/showcase.html">showcase</a>.<br />
Cool, but what has this project to do with CakePHP? Well, gwoo recently created <a href="http://cakeforge.org/projects/cakeamfphp/">CakeAMFPHP</a>, a CakeForge project which just yesterday reached its <a href="http://rd11.com/posts/view/21">0.4.0 release</a>, and it&#8217;s fully compatible with <span class="caps">AMFPHP</span> 1.2.3 and CakePHP 0.10 final.<br />
Here&#8217;s an excerpt taken from CakeAMFPHP <span class="caps">README</span>.txt file:</p>
<blockquote>
<p>&#8220;[&#8230;] <br />
1) get CakePHP 0.10 final (http://cakephp.org)<br />
2) get amfphp 1.2.3 (http://amfphp.org)<br />
3) get the <span class="caps">UFO</span> js http://www.bobbyvandersluis.com/ufo/<br />
4) put amfphp into /app/vendors<br />
5) put cakeamfphp into vendors<br />
6) put the cake_gateway.php in /app/webroot<br />
7) put the cakeamfphp.php in /app/views/helpers<br />
8) put CakeMySqlAdpater.php in /app/vendors/amfphp-core/adapters<br />
9) Voila: NetServices.setDefaultGatewayUrl( &#8216;http://localhost/cake_install/cake_gateway.php&#8217;);<br />
Access the service browser through<br />
http://localhost/cake_install/vendors/cakeamfphp/cakebrowser/&#8221;</p>
</blockquote>
<p>The installation doesn&#8217;t seem too painful at all. And &#8211; guess what &#8211; gwoo recently updated a very informative tutorial showing how to create a simple &#8211; but still impressive &#8211; bullettin board with CakeAMFPHP.</p>
<p><em>&#8220;Cool, but I never liked flash, what about <span class="caps">AJAX</span>?&#8221;</em></p>
<p style="float:left;"><img src="http://base--/img/pictures/qooxdoo.gif" alt="" /></p>
<p>CakePHP has a nice <span class="caps">AJAX</span> helper to be used in conjunction with <a href="http://prototype.conio.net/">prototype</a>, but there are truly a lot of libraries, mini-frameworks, pre-built applications to create interactive desktop-like user interfaces. Some people may already know <a href="http://qooxdoo.oss.schlund.de/">qooxdoo</a>,</p>
<blockquote>
<p>&#8220;[&#8230;] an advanced open-source JavaScript-based <span class="caps">GUI</span> toolkit. qooxdoo continues where simple <span class="caps">HTML</span> is not enough. This way qooxdoo can help you implement your <span class="caps">AJAX</span>-enhanced web 2.0 application &#8211; easier than ever before.&#8221;</p>
</blockquote>
<p>In a recent <a href="http://groups.google.com/group/cake-php/browse_thread/thread/ba219c64cd794764/1d77973293514618?lnk=raot">discussion</a> on CakePHP user group someone suggested the possibility to integrate qooxdoo with CakePHP. Apparently qooxdoo people were <a href="http://www.nabble.com/Re%3A-qooxdoo-PHP-framework-project-p3799302.html">evaluating</a> various <span class="caps">MVC</span> frameworks, and Cake was obviously listed together with two other Rails clones for <span class="caps">PHP</span>. The good news is that <a href="http://cakeforge.org/users/a100rk/">100rk</a> just started a new project called <a href="http://cakeforge.org/projects/cqx"><span class="caps">CQX</span></a>, which &#8211; although still in pre-alpha a development demo is already available, and it <em>shows off</em> most of qooxdoo&#8217;s features&#8230; <a href="http://cqx.100rk.org/trunk/">Take a look</a></p>
<p>Best of luck to 100rk and his brand new project, I really hope to see more of it soon!</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-04-06:/articles/8/</id>
    <title>New site operative</title>
    <published>2006-04-06T14:57:00Z</published>
    <updated>2009-09-06T18:10:48Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/8/"/>
    <category term="website" scheme="http://www.h3rald.com/tags/website/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <content type="html">
<![CDATA[
<p>Yes, it works. Perhaps it&#8217;s a tiny bit slower than expected but the new h3raLd.com seems to work.<br />
I&#8217;ll probably find some new exciting bugs to fix in the next few hours, as usual &#8211; that will be annoying but perfectly normal.</p>
<p><del>The good thing is that the new template seems to load faster, mostly due to the fact that I hardly used images</del> &lt;- [not true, te new site appears to be slower, maybe not due to the images], at any rate, let&#8217;s see how it goes. I can imagine I&#8217;ll have to implement some sort of caching system for the tagging system in particular, but fortunately <a href="http://www.cakephp.org/">CakePHP</a> apparently comes with a built-in caching mechanism for views, models etc. etc. although the documentation available seems to be <a href="http://groups.google.com/group/cake-php/browse_thread/thread/f0f96751bb61bc7b/bcb43c97e91923c7?q=caching&amp;rnum=1#bcb43c97e91923c7">scarce</a> at the moment, and I&#8217;ve been to lazy to investigate any further.</p>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-01-11:/articles/a-look-at-drupal/</id>
    <title>A look at Drupal</title>
    <published>2006-01-12T06:42:44Z</published>
    <updated>2009-09-06T18:10:47Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/a-look-at-drupal/"/>
    <category term="php" scheme="http://www.h3rald.com/tags/php/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <category term="review" scheme="http://www.h3rald.com/tags/review/"/>
    <content type="html">
<![CDATA[
<em><strong>Important Notice:</strong> This article is about changes occurring to zZine Magazine's site[1]. At the time of writing, <a href="www.zzine.org">www.zzine.org</a> uses the old site, and not the Drupal-based one presented in this article, which is currently under construction[18].</em><br />
<br />
"Why can't we log who edits the articles?"<br />
"Can we send newsletters?"<br />
"We should really have a members' area..."<br />
<br />
zZine.org[1] is a scratch-built site, coded from the ground up to offer zZine journalists, editors and readers all the functionalities and features they wanted.  I'm not totally against sites being coded from scratch, but what happens if something needs to be fixed, or new functionalities have to be implemented and you realize that the code cannot be extended or patched easily?<strong>Case Study: zZine Magazine</strong><br />
<br />
zZine Magazine is an online magazine which publishes not only IT-related and other articles on a weekly basis, but also monthly publications containing CyberArmy[2] digests, special columns, and featured articles. A team of journalists, researchers, editors, publishers and outside contributors has access to the zZine site to write, submit, and edit articles, manage publications and perform various other tasks through a password-protected administration area. This is common to approximately 75% of the websites on the Internet: they have a front-end to present content to the general public and a semi-hidden administration backend which is normally more difficult and tedious to code. That's why someone started developing <em>Content Management Systems</em>[3]: ready-made, fully-featured administrative back-ends for creating and managing almost any kind of website, from blogs to eCommerce portals.<br />
<br />
Could a CMS be used for zZine Magazine? Probably - zZine doesn't need any innovative or advanced features, just a bunch of commonly-used functionalities like:<br />
<ul><br />
 	<li>Add, delete, edit and publish articles<br />
 	</li><li>Customizable user permissions, ideally role-based </li>(writer, editor, publisher, etc.)<br />
 	<li>Creating and managing monthly publications<br />
 	</li><li>Editor's tests<br />
 	</li><li>User signups, notifications, etc.<br />
 	</li><li>RSS feed generation<br />
 	</li><li>Sending newsletters to subscribers<br />
 	</li><li>Logging user actions<br />
</li></ul><br />
Some members of my team raised some concerns regarding the usage of a CMS, which were mostly based on our past experience with just a particular product and not CMSes in general. Everybody agreed that if we were to go back to a CMS, we <em>had</em> to choose the <em>best</em> this time: something flexible, easy to use, fast, search-engine friendly, and extensible.  I  spent some time researching CMSes, because while I knew that there's no such thing as the best CMS, there was certainly a CMS that was best for our needs.<br />
<br />
<br />
<strong>Making the right choice</strong><br />
<br />
In the past, I had played around with Xoops[4] when I first thought about creating websites, and I used Mambo[5] for some other sites. I admit that I never actually spent time creating complex Mambo components and modules, but I must say that in the end I felt somehow tied to third-party modules and unable to understand how they really worked: Mambo seemed to give developers too much freedom, and had neither a solid API nor conventions to follow, at least when I used it.<br />
<br />
So I decided to have a look around again, starting from the two most important sites people should look at when choosing the most suitable CMS for their work. <br />
The first site is CMS Matrix[6] which - as the name implies - provides a really handy <em>matrix</em>, or chart, to compare the various features offered by nearly all CMS available, both proprietary and open-source.<br />
<br />
I remember choosing Mambo last time I used the matrix simply because it appeared to be one of the most feature-rich. This is actually something <em>not</em> to do when choosing a CMS: always concentrate on what your site needs rather than what the CMS is able to offer.  Otherwise, you run the risk of having too much to work with.<br />
<br />
The other important website to visit when choosing a Content Management System is OpenSourceCMS[7], which basically allows you to try a demo of every open source CMS online. This is perhaps more useful, but also much more time-consuming: it's better to narrow down the list of possible CMSes after checking CMS Matrix and then try each one rather than just picking one at  random.<br />
<br />
At this point, an experienced CyberArmy staff member[8] suggested Drupal[9]. I asked her why, and she simply said that it seemed to be the best choice according to zZine's needs, as it basically offered all the features we were looking for, either natively or through modules. She also admitted to be biased, as she's actually <em>part of Drupal's documentation team</em> and involved with Drupal development[10].<br />
<br />
Before making any kind of commitment, I checked out Drupal's website to see how they organized things, and I was quite impressed. I immediately noticed the Handbooks section[11], which contains all the official Drupal documentation and it seemed pretty much complete. No "under construction", "please write content here" or "we're a new project, help us write the documentation" notes, just a load of good-quality documentation, including a fully documented and <em>stable</em> API![12]  <br />
<br />
This surprised me, because some projects I came across, even really good ones, lacked a proper documentation section. I think this is a common problem with new open source projects, and Drupal for this reason gave me the impression to be quite mature and useable already.  After visiting the very clear and organized Downloads Section[13], I downloaded the CMS and a few modules and installed it on my laptop.<br />
<br />
<br />
<strong>Installation</strong><br />
<br />
Drupal needs three things to run:<br />
<ul><br />
 	<li>A web server  -  Apache is fine, and ISS is reported to be working<br />
 	</li><li>PHP - Either version 4 or 5, Drupal started supporting PHP5 since 4.6.0 release<br />
 	</li><li>A PHP-compatible database - MySQL or PostgreSQL is recommended<br />
</li></ul><br />
I used a WAMP[14] installation to test Drupal.  First of all, I created a MySQL database, granting ALL privileges to the database user accessing the Drupal database. When I uploaded the site to the remote server, later on, I had some problems because the LOCK TABLES privilege wasn't granted by the host. Drupal requires this, so I had to contact my host to solve the problem.  I then imported the database scheme located in the <em>database</em> directory under the installation directory and modified the configuration settings (sites/default/settings.php) to allow Drupal to access the database.  Installation complete.<br />
<br />
Drupal was now up and running with the default configuration settings, with a minimum of fuss. For all the details concerning the installation process, consult the exhaustive documentation.[15] I didn't read it when I installed it, but it can really be useful in some situations.<br />
<br />
 There are actually two non-critical things to consider if you're planning to use Drupal for a medium-sized project: the first involves changing a few settings on php.ini, in particular increasing the amount of memory allocated to PHP from 8MB to 16MB, especially if you're planning to use either a lot of  simple modules or a few complex ones, and the second is setting up your crontab to execute <em>http://www.yoursite.com/cron.php</em> every hour or so.  This is required by some semi-essential modules like the site-wide search, but a common alternative (if you don't want to setup the <em>cron</em> task manually) is the poorman's <em>cron</em> module[15], which I used myself and found to be workable. <br />
<br />
<br />
<strong>Keeping your site under control</strong><br />
<br />
Perhaps one of the best things Drupal has to offer is a rock-solid general-purpose administrative backend. The first thing I found in the backend which really impressed me (and that also I never found in another CMS) is the ability to create <em>custom</em> role-based user accounts and access permissions for <em>everything</em>: every module can be configured so that, for example, not all people can see its output and just a few can administer and modify it.<br />
<br />
For zZine, I created four types of accounts:<br />
<ul><br />
 	[*]<em>Administrator</em> - Able to access everything and change every setting of the site<br />
 	[*]<em>Publisher</em> - Able to write, edit and publish every kind of content on the site, but not able to administer user accounts, permissions and similar administrator-only tasks.<br />
 	[*]<em>Editor</em> - Able to write and edit anything on the site, but not to publish it.<br />
 	[*]<em>Writer</em> - Able to write articles, blogs and similar content, but in some cases not allowed to edit it.<br />
</ul><br />
These were precisely the account types I was looking for in a CMS. Granted, other products offer them by default, but having pre-defined account types is one thing, and being able to customize them completely is another.<br />
<br />
User accounts are great, but sometimes it's good to know what the users of your sites are doing as well. On our old site we had user accounts for editors and administrators, and even if only a few people had access we had no way to determine who edited an article or who published something unless that person told us.  Drupal comes with a radical solution to this: Almost every action is automatically logged by the <em>watchdog</em> core module. Every website error, every page not found, and every PHP or MySQL error is logged, as well as every content submission or modification.  Page accesses, meanwhile, can be logged through the statistics module. <br />
<br />
Themes &amp; Templates<br />
<br />
"We shouldn't use a CMS: I don't want zZine to have the overly used *nuke-style look."  I've heard this too many times. Sometimes people associate the word "CMS" with "lack of original design", and that's not true by any means, especially for Drupal.  Of course, there are plenty of ready made themes[16] which can be freely used or modified for any Drupal-based site. <br />
<br />
I must confess that when I first saw the themes section I feared that Drupal "themes" used their own template engine, like some CMSes do nowadays, but I was wrong: currently Drupal supports some template engines[17] but also pure PHP-based ones. Theme engines do their job wonderfully and can offer some interesting features, but templates written natively in PHP tend to perform better, simply because there's no extra parsing or additional overhead involved.<br />
<br />
I decided to have a look at a standard PHP theme. Basically, it's nothing more than a PHP-enriched xHTML file and its corresponding stylesheet. There are a few functions which must be used to perform particular tasks, like showing the main navigation links, but nothing too hard to understand.  It's also <em>very</em> customizable.  In fact, we're already working on a custom zZine theme, which doesn't seem any harder than coding a standard xHTML template. As design should always be the last thing to worry about, I decided to use a temporary template I created by slightly modifying an existing one.[18]<br />
<br />
<br />
<strong>To switch or not to switch?</strong><br />
<br />
When creating a new site for an organization which already has one, there's something very important to consider: <em>what happens to the old data</em>?<br />
Assuming the old site was dynamic and using a database of some sort, there are three possibilities:<br />
<ul><br />
 	<li>Don't bother doing anything: any data on the old site will not be transferred to the new one.<br />
 	</li><li>Make the old website available somewhere else as an </li><em>archive</em> of old documents.<br />
 	<li>Import all the data from the old site to the new one. <br />
</li></ul><br />
Obviously we went straight for the third one, which is the most difficult to implement, but it was necessary: there were over 1000 articles on the old site-<br />
<br />
Of course, in reality, I didn't even mention the possibility of using Drupal until I figured out a way to import the old data into the new database structure. Never praise features or convince people to switch unless you're 100% sure you can handle the situation.  Luckily for me, it turned out that everything could be imported easily enough.<br />
<br />
The first difference I found between Drupal and zZine was that we didn't really have proper user accounts. Every article had an author, but it was stored as a field in the article's record, and that was all. Drupal, on the other hand,  supports (and perhaps requires) user accounts - everything present on the site must be written or edited by an existing user.<br />
<br />
The solution I cam eup with was rather drastic: I created about 120 user accounts, retrieving usernames from the articles and inserting them through a custom PHP script into Drupal's user table. Of course, those users never registered on the new site[18], so I didn't personalize the accounts at all: I simply put a notice on the first page asking everyone who contributed to zZine before to contact me in some way to enable their account with a valid email address.<br />
<br />
After this initial difficulty, importing articles was relatively easy. Pretty much every type of content in Drupal is, in its simplest form, a <em>node</em>. Nodes have a title, which is a teaser generated automatically from the body text, and an author (the node table in the database has more fields, but these are the key ones for us). Essentially, Drupal's two default models for writing <em>stories</em> and <em>pages</em> write data to this table only.  The most important thing to understand about Drupal is that almost every module used to create <em>something</em> on the site - an article, a blog entry, even songs - will use the node table, and add everything else on other tables.  This makes the whole system much easier to administer: every node can potentially be extended <em>in any way</em> by third party modules!  <br />
<br />
What about categories? Well, Drupal has become famous for its taxonomy module: whereas most CMSes only support, or in fact <em>impose</em>, a one- or two-level hierarchy for categories, Drupal's taxonomy module supports the creation of as many different terms to describe data as you can think of. Each piece of content (categorization can be applied to <em>any</em> node, and since almost everything is a node-) can belong to none or <em>n</em> different categories, which can be nested in a <em>n</em>-level hierarchy.  Since the zZine articles were already divided into categories, I imported all of them directly into Drupal.  On the old zZine site, every article could have at most one category, which is fine, but it's good to know that we can now configure the system to support a more advanced categorizing system.<br />
<br />
After importing the articles, the last important thing to transfer to the new site were the zZine Publications. Publications are what we call the article collections that we release as an issue every month.  I could have created a new module for this, and it wouldn't have been that hard, but there was already an excellent module for that. This was pure luck, but the <em>epublish</em>[19] module seemed like it was tailored specifically for our needs.<br />
<br />
<br />
<strong>Drupal API and Modules</strong><br />
<br />
We were lucky enough to be able to use existing modules for the main functionalities of our site, but in some cases you might not be able to find <em>exactly</em> what you're looking for.<br />
 <br />
In our case, even if we could have used the <em>story</em> module, which is part of the default installation, for zZine articles (stories have a body, a teaser,  a title and an author, exactly like our articles) we decided not to. I wanted our editors and writers to know what to use when submitting articles, and the name "stories" sounds a bit too ambiguous for my liking.  So, I decided to have a look at the standard story module to see how modules work, and create something similar.<br />
<br />
<em>Note: I'm curious by nature and I didn't read anything in the Drupal API[12], or about developing custom modules; I looked at the story module without any prior knowledge of Drupal's conventions.</em><br />
<br />
All I found in the story module was a bunch of functions like:<br />
<code><br />
/**<br />
 * Implementation of hook_node_name().<br />
 */<br />
function story_node_name($node) {<br />
  return t('story');<br />
}<br />
</code><br />
<br />
  which seemed to be enough to tell the Drupal core what to do. I was used to Mambo components, where developers have more liberty to do what they want, including outputting HTML code anywhere. Drupal is nothing like that; on the contrary, it has its own structure and coding conventions that developers have to follow when creating custom modules. Even if a simple function like the one above is fully commented, it has to have a standard indentation (two spaces) and an obviously standardized name. I noticed that all the functions similar to this one started with "<em>story_</em>", so I created a new file named <em>zzarticle.module</em>, copied and pasted the story module code into it, and changed every function accordingly, like this:<br />
<code><br />
/**<br />
 * Implementation of hook_node_name().<br />
 */<br />
function zzarticle_node_name($node) {<br />
  return t('zZine Article');<br />
} <br />
</code><br />
Trivial enough, and it worked fine! I put my shamefully copied module in the /modules directory and I was able to create "zZine Articles" (which were nothing but stories with a different name).<br />
<br />
At this point I decided to have a proper look at the API, and read about hooks:<br />
<br />
<fieldset><blockquote><em>"Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.<br />
 To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and call that hook in all enabled modules that implement it. [-]"</em></blockquote></fieldset><br />
A <em>hook</em> was used for the previously mentioned function, and this was diligently commented:<br />
<br />
<code><br />
/**<br />
 * Implementation of hook_node_name().<br />
 */<br />
</code><br />
<br />
This made me understand how Drupal is actually geared towards developers and at the same time suitable for non-technical users.  Wait a minute, what if someone is not familiar with PHP and still needs custom modules and features? Is there any way to extend Drupal without having to physically code new things? Yes, there is, and two modules come to mind:<br />
<ul><br />
<br />
 	[*]<em>Webform</em> - allows the creation of any kind of web form. Users can customize field types, values, labels and messages.  The module also provides ways to process forms by either saving data to the database or emailing it, which we can use for things like the Editor's Test and surveys.<br />
 	[*]<em>Flexynode</em> - This module is simple and powerful - it allows users to create their own content types without coding a single line. In my example, I cloned the story module to create the zZine Article content type. This is easy to do, and functional, but what happens if someone wants to include an additional field to the article submission form? I can probably do this using hooks, but if I was lazy I could do the same thing with the <em>flexynode</em> module. I actually used this module for our podcast section[20], and it did an excellent job.<br />
</ul><br />
<br />
<strong>Conclusions</strong><br />
<br />
For now I must say I'm very happy with what Drupal has to offer, and if there's something we need for the site, we can code it ourselves and then integrate it into Drupal. <br />
One of the major strengths of this CMS is definitely its developer-friendliness: while other CMSes mainly focus on users at the price of limiting extensibility and trapping developers into predefined modules, Drupal even encourages developers to integrate their code into the existing structure, opening virtually unlimited possibilities. Granted, it may seem difficult to understand at first, some people I talked to told me that 'Drupal is too complex' or has a rather steep learning curve, but I just think everything becomes clearer after reading parts of the vast documentation section: this is the only price to pay, and believe me, it is definitely worthwhile.<br />
<br />
  <br />
<strong>Notes</strong><br />
[small]<br />
[1] zZine Magazine: <a href="http://www.zzine.org">http://www.zzine.org</a><br />
[2] CyberArmy Community: <a href="http://www.cyberarmy.net">http://www.cyberarmy.net</a><br />
[3] Content Management System, Wikipedia page: <a href="http://en.wikipedia.org/wiki/Content_management_system">http://en.wikipedia.org/wiki/Content_management_system</a><br />
[4] Xoops - Official Page <a href="http://www.xoops.org/">http://www.xoops.org/</a><br />
[5] Mambo - Official Page: <a href="http://www.mamboserver.com">http://www.mamboserver.com</a><br />
[6]CMS Matrix: <a href="http://cmsmatrix.org/">http://cmsmatrix.org/</a><br />
[7] Open Source CMS:  <a href="http://opensourcecms.com/">http://opensourcecms.com/</a><br />
[8] Snarkles's CyberArmy Profile: <a href="http://www.cyberarmy.net/~snarkles">http://www.cyberarmy.net/~snarkles</a><br />
[9] Drupal - Official Page: <a href="http://www.drupal.org">http://www.drupal.org</a><br />
[10]Webchick's Drupal Profile: <a href="http://drupal.org/user/24967">http://drupal.org/user/24967</a><br />
[11] Drupal - Handbooks: <a href="http://www.drupal.org/handbooks/">http://www.drupal.org/handbooks/</a><br />
[12] Drupal API: <a href="http://drupaldocs.org/api/head">http://drupaldocs.org/api/head</a><br />
[13] Drupal Downloads: <a href="http://www.drupal.org/project/">http://www.drupal.org/project/</a><br />
[14] WAMP Server Package: <a href="http://www.wampserver.com">http://www.wampserver.com</a><br />
[15] Drupal - Installing and Upgrading documentation: <a href=" <a href="http://drupal.org/node/258"> <a href="http://drupal.org/node/258</a>">http://drupal.org/node/258[/url]</a><br />
[16] Drupal - Themes: <a href="http://drupal.org/project/Themes">http://drupal.org/project/Themes</a><br />
[17] Drupal - Theme Engines: <a href="http://drupal.org/node/509">http://drupal.org/node/509</a><br />
[18] zZine Beta site: <a href="http://beta.zzine.org">http://beta.zzine.org</a><br />
[19] Drupal - ePublish module: <a href="http://drupal.org/project/epublish">http://drupal.org/project/epublish</a><br />
[20] zZine Podcasts: <a href="http://beta.zzine.org/podcasts">http://beta.zzine.org/podcasts</a><br />
[/small]]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2006-01-11:/articles/what-is-ajax/</id>
    <title>What is AJAX?</title>
    <published>2006-01-12T06:30:08Z</published>
    <updated>2009-09-06T18:10:46Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/what-is-ajax/"/>
    <category term="internet" scheme="http://www.h3rald.com/tags/internet/"/>
    <category term="web20" scheme="http://www.h3rald.com/tags/web20/"/>
    <category term="ajax" scheme="http://www.h3rald.com/tags/ajax/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[
<em>"The Web is changing. The 30-year-old terminal-like technology it was originally is gradually giving way to new ways of doing things. The power of AJAX allows for rich user interaction without the trouble that has bugged traditional web applications."</em>This is the introduction to the script.aculo.us[1] website, and regardless your opinion about the so-called AJAX <em>programming technique</em>, they are fundamentally right: the web is changing.  AJAX is at least one way to do things in a different way, enhancing - although arguably, in some cases -  users' browsing experience.<br />
<br />
<strong>Application examples</strong><br />
What is AJAX then? Nothing too new, but not too old either. I'd define AJAX as the <em>rebirth of Javascript</em>, for example, it's not only Javascript we're talking about. The acronym stands for Asynchronous Javascript And XML and it already gives an idea of the fundamentals of the technology: something build on <em>asynchronous server requests and responses </em>. This may be clear to coders, but the best way to try explaining this to everyday internet users is showing some famous applications:<br />
<br />
<em>Gmail[2]</em>: The first example? The most famous? The most used? Perhaps. Google aimed to impress both end users and geeks with it's free, long awaited email service. What's so unusual in this webmail application?<br />
<ul><br />
<li>An innovative and intuitive interface, more similar to a desktop application than a traditional webpage.<br />
</li><li>Rich formatting through an effective, easy-to-use editor.<br />
</li><li>Online spell checker.<br />
</li><li>Instant </li>(one click) email tagging, labels, contact groups etc.<br />
<li>Email auto save.<br />
</li></ul><br />
<br />
<em>Kiko[3]</em>: This is a very neat online calendar, free to use and customizable. Features include:<br />
<ul><br />
<li>Multiple user/contacts/events administration.<br />
</li><li>Personalization of the right click menu </li>(it overrides your browser's default behavior).<br />
<li>Drag and drop events across the calendar.<br />
</li><li>Easily switch through different calendar views without any page refresh.<br />
-	</li></ul><br />
<br />
<em>Writely[4]</em>: An online word processor. Although it is not as advanced as its desktop's cousins, this is a truly admirable effort to port a desktop application to the web. The service is free for now and it allows users to create, edit, share and export text documents. Among its features there are:<br />
<ul><br />
<li>High degree of document formatting - modify font size, style, colors, alignment, insert images and links etc.<br />
</li><li>Enhanced exporting options - it can create html documents, Word documents, zip files etc.<br />
</li><li>Online spell-checker.<br />
</li><li>Ability to easily share and publish your work.<br />
</li></ul><br />
<br />
This list can continue[5], as new "AJAX-powered" applications are created nearly every day. <br />
<fieldset><blockquote>AJAX provides the web developer the ability to create web applications that look and feel like applications that run on the desktop. It does this by solving the 'partial update' problem. AJAX makes it possible for a web application to request data from the server (usually in response to a button click or other java script 'event') and change a part of the current page to reflect the result of the query. Prior to AJAX, if the web developer wanted to retrieve any information from the server a full page update was required. This may mean a full page load when the user clicks a help icon, spell checks a document or performs a drag and drop operation that changes data on the server. AJAX solves this problem and opens the door for a host of AJAX-powered web applications<br />
There were some unconventional solutions to this problem prior to AJAX. I have ignored them for the purpose of this article as they were hacky or relied on a feature in a particular browser </blockquote></fieldset><br />
<br />
<strong>How does it work?</strong><br />
Ajax[7] is fundamentally the union of various technologies - not something new by itself:<br />
<ul><br />
<li> </li>(X)HTML, CSS, etc., used as presentation layer and format the information retrieved by the server: nothing special here.<br />
<li>The XMLHttpRequest</li>[8] object, which allows data exchange between client and server "silently", in an asynchronous way, without the need of refreshing and reloading a whole web page<br />
<li>The Dom Object Model </li>(DOM)[9], a Object-Oriented way to represent and access HTML or XML.<br />
<li>XML and XSLT used for data interchange and manipulation<br />
</li></ul><br />
<br />
The magic is undoubtedly in the XMLHttpRequest object, originally invented by Microsoft as an ActiveX object and then made available as a standard Javascript class by Mozilla-based browsers. At least something which <em>seems</em> to be compatible with <em>most</em> browsers then.<br />
<br />
A necessary step in any Javascript script using the XMLHttpRequest object would be something like:<br />
<br />
<code><br />
if (window.XMLHttpRequest) { // Mozilla, Safari, ...<br />
    http_request = new XMLHttpRequest();<br />
} else if (window.ActiveXObject) { // IE<br />
    http_request = new ActiveXObject("Microsoft.XMLHTTP");<br />
}<br />
</code><br />
<br />
In order to have an http_request object to use later on which is independent from the browser type.<br />
<br />
Let's now examine an example of elementary Ajax application[10]. The following code is broken into different parts and commented, the uncommented source and a demo is available on degraeve.com[10].<br />
<br />
For this simple example we need to create a simple server-side script which will be called by our Ajax application. The script can be in any language, this one is in Perl.<br />
<br />
<code><br />
#!/usr/bin/perl -w<br />
use CGI;<br />
<br />
$query = new CGI;<br />
<br />
$secretword = $query-param('w');<br />
$remotehost = $query-remote_host();<br />
<br />
print $query-header;<br />
print "&lt;p&gt;The secret word is &lt;b&gt;$secretword&lt;/b&gt; and your IP is &lt;b&gt;$remotehost&lt;/b&gt;.<br />
 </code><br />
<br />
Basically it creates a new CGI object named $query, used to access the parameter which will be passed by our submission form, "w", and get the user's IP address.<br />
The script will then print a the page header and a phrase containing the word entered in our form and the user's IP address.<br />
<br />
And here's the simple Ajax application:<br />
<br />
<code><br />
&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Simple Ajax Example&lt;/title&gt;<br />
<br />
&lt;script language="Javascript"&gt;<br />
</code><br />
<br />
<em>Comment: Just the first HTML tags of the page, and the beginning of the script</em><br />
<br />
<code><br />
function xmlhttpPost(strURL) {<br />
    var xmlHttpReq = false;<br />
    var self = this;<br />
    // Mozilla/Safari<br />
    if (window.XMLHttpRequest) {<br />
        self.xmlHttpReq = new XMLHttpRequest();<br />
    }<br />
    // IE<br />
    else if (window.ActiveXObject) {<br />
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");<br />
    }<br />
</code><br />
<br />
<em>Comment: First of all we create a function named xmlhttpPost, which takes the parameter strURL, i.e. the web address of the script we created earlier. In the first part of the function, we create the HTMLHttpRequest object independently of the browser, which in this case is called self.xmlHttpReq. </em><br />
<code><br />
 <br />
    self.xmlHttpReq.open('POST', strURL, true);<br />
<br />
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');<br />
</code><br />
<br />
<em>Comment: with the method open we initialize the connection, specifying that we want to send a POST request to the page "strURL" and that the connection is asynchronous (true). The third parameter is actually true by default and could have been omitted in this case. <br />
As we want to use the POST method, we need to set the content-type header for our request, in this case "application/x-www-form-urlencoded". </em><br />
<br />
<code><br />
    self.xmlHttpReq.onreadystatechange = function() {<br />
        if (self.xmlHttpReq.readyState == 4) {<br />
            updatepage(self.xmlHttpReq.responseText);<br />
        }<br />
    }<br />
    self.xmlHttpReq.send(getquerystring());<br />
}<br />
</code><br />
<br />
<br />
<em>Comment: This is the crucial part, as we need to send the request and also define the behavior of our application once the response is received. The request is sent using the "send" method, which sends a properly formatted query string (see below), but before that we need to setup a "listener" to monitor what happens to our request.<br />
The readyState variables is updated according to the status of the connection, and can assume the following values:<br />
<ul><br />
<li>0 - Uninitialised<br />
</li><li>1 - Loading<br />
</li><li>2 - Loaded<br />
</li><li>3 - Interactive<br />
</li><li>4 - Completed<br />
</li></ul><br />
<br />
We want to update our page once we are sure that the connection with the script has been established, therefore we setup a listener (onreadystatechange) to update the page via the function update page defined below only if the connection's state is "Completed" (self.xmlHttpReq.readyState == 4). The  self.xmlHttpReq.responseText variable which is sent to the update page function contains the response generated by our CGI script. </em><br />
<br />
<code><br />
function getquerystring() {<br />
    var form     = document.forms['f1'];<br />
    var word = form.word.value;<br />
    qstr = 'w=' + escape(word);  // NOTE: no '?' before querystring<br />
    return qstr;<br />
}<br />
</code><br />
<br />
<em>Comment: This function simply formats the parameter sent to the script as "w=typedword" where "typedword" is the word typed in the form of our application. </em><br />
<br />
<code><br />
function updatepage(str){<br />
    document.getElementById("result").innerHTML = str;<br />
}<br />
</code><br />
<br />
<em>Comment: Finally, this function inserts the response we got from the CGI script into an HTML element with id=result, through the method innerHTML. </em><br />
<br />
<code><br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
<br />
&lt;form name="f1"&gt;<br />
  &lt;pword: &lt;input name="word" type="text"  &gt;<br />
  &lt;input value="Go" type="button" &gt;onclick='JavaScript:xmlhttpPost("/cgi-bin/simple-ajax-example.cgi")'&lt;/p&gt;<br />
  &lt;div id="result"&gt;&lt;/div&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;<br />
</code><br />
<br />
<em>Comment: This is the final part of the application, which defines our form containing a text field and a submit button. Note that our xmlhttpPost function is called once the button is clicked, through the on click attribute. </em><br />
<br />
That's it. <br />
The first reaction after reading so far would probably be "Ajax is not easy at all", well, I never said it was. To create a simple application which just prints something on the screen we had to go through a lot of code, and we could have done something similar with much less hassle. This was just a trivial example, very different from those large scale applications available online.<br />
<br />
There's good news though, there are plenty of frameworks and toolkits which makes life easier for developers interested in using this programming technique. There are in particular various libraries built upon the Prototype[11] framework such as the already mentioned Script.aculo.us[1] and Rico[12] for examples, and various frameworks which integrate Ajax in some way in any server side language, like Ruby on Rails[13] or CakePHP[14], for example.<br />
<br />
<strong>Conclusion</strong><br />
Undoubtedly Ajax can be used to create really powerful and innovative applications, but it shouldn't be abused or mis-used. There are a few things to keep in mind, when developing an Ajax application:<br />
<ul><br />
<li>It requires Javascript to be enable on the client browser, and the developer obviously can't control that<br />
</li><li>The application may not compatible with all browsers, in particular older browsers will definitely not be able to access it.<br />
</li><li>It can be too much of a surprise for the user who never used an Ajax application before: it may experience delays in responses, some basic functionalities like the "Back" button might not work as expected etc.<br />
</li></ul><br />
<br />
There are actually many more things to consider [15] before even start planning to develop an application, and can basically be summarized as follows:<br />
<br />
<em>"Do not use Ajax in your web application unless you know what you're doing"</em><br />
<br />
Luckily, there are a lot of articles and resources[16] out there, waiting for you.<br />
<br />
<br />
<strong>Notes and Resources</strong><br />
[small]<br />
[1] Script.aculo.us AJAX toolkit: <a href="http://www.script.aculo.us ">http://www.script.aculo.us </a><br />
[2] Gmail - Google's online webmail: <a href="http://mail.google.com/mail">http://mail.google.com/mail</a><br />
[3] Kiko  - Online calendar: <a href="http://www.kiko.com/">http://www.kiko.com/</a><br />
[4] Writely - Online word processor: <a href="http://www.writely.com/">http://www.writely.com/</a> <br />
[5] A venture forth Blog - Top 10 Ajax applications: <a href="http://www.aventureforth.com/?p=13">http://www.aventureforth.com/?p=13</a><br />
[6] HTTP - Webopedia entry: <a href="http://www.webopedia.com/TERM/H/HTTP.html">http://www.webopedia.com/TERM/H/HTTP.html</a><br />
[7] AJAX - Wikipedia Page: <a href="http://en.wikipedia.org/wiki/AJAX">http://en.wikipedia.org/wiki/AJAX</a><br />
[8] XMLHTTP Wikipedia Page: <a href="http://en.wikipedia.org/wiki/XMLHTTP">http://en.wikipedia.org/wiki/XMLHTTP</a><br />
<br />
[9] Dom Object Model - Wikipedia Page: <a href="http://en.wikipedia.org/wiki/Document_Object_Model">http://en.wikipedia.org/wiki/Document_Object_Model</a><br />
[10] degraeve.com - Simple Ajax Example: <a href="http://www.degraeve.com/reference/simple-ajax-example.php">http://www.degraeve.com/reference/simple-ajax-example.php</a><br />
[11] Prototype Javascript Framework: <a href="http://prototype.conio.net/">http://prototype.conio.net/</a><br />
[12] Rico open-source Javascript library: <a href="http://openrico.org/">http://openrico.org/</a><br />
[13] Ruby on Rails: <a href="http://www.rubyonrails.org">http://www.rubyonrails.org</a><br />
[14] CakePHP framework: <a href="http://www.cakephp.org">http://www.cakephp.org</a><br />
[15] Alex Bosworth's Weblog: Ajax Mistakes: <a href="http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html">http://sourcelabs.com/ajb/archives/2005/05/ajax_mistakes.html</a><br />
[16] AjaxMatters.com: <a href="http://www.ajaxmatters.com/r/welcome">http://www.ajaxmatters.com/r/welcome</a><br />
[/small]]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2005-12-09:/articles/web-promotion/</id>
    <title>Zero-cost website promotion - Part I</title>
    <published>2005-12-09T13:08:27Z</published>
    <updated>2009-09-06T18:10:45Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/web-promotion/"/>
    <category term="internet" scheme="http://www.h3rald.com/tags/internet/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[
Everybody from magazines to canned pasta sellers wants a website to promote their business, but you need to promote your site before you promote your products or services through it.  In Part 1 of this article, I will explain some of the basics of promoting a website, and show you how to implement a cost-free strategy to get the search engine placement you need to promote your website.<strong>The Necessity of Website Promotion</strong><br />
As the World Wide Web kept growing over the years, people soon realised that keeping updated <em>list</em>s of all the available pages on the Net was an impossible and pointless job.  It became necessary to develop a new way to easily find and access the massive amount of content on the Web, and that is when <em>search engines</em> became a reality.<br />
<br />
Everyone should know the <em>legend</em> of the two lads from Stanford University who became multi-millionaires in a few years after developing and successfully marketing their easy-to-use, ultra-powerful search engine called Google. <br />
<br />
After it became clear that the Web was going to be (quite literally) dominated by search engines, IT professionals started developing strategies to cause their site to appearon the first page of search results. These strategies and techniques soon became known as <em>Search Engine Optimizations</em> (SEO). Call it ?science?, ?magic? or simply a way to make money, SEO is a business, and so-called "SEO experts" often <em>do</em> get a lot of cash just to take care of your website.<br />
<br />
Whether you like it or not, any website must be promoted in order to get visitors; some sort of marketing strategy <em>is</em> necessary if you want to stand out from the crowd, and  even if you just want someone to find your page.<br />
<br />
Now let's assume that you don't want to spend a penny marketing your site, but you still want to be known and noticed among either competitors or friends and get some visitors to your new, exceptional (for you) and extremely innovative (to your eyes) website.  Is it possible to do this, or do you need to shell out some money to an SEO expert'<br />
<br />
I think that a zero-cost marketing strategy does exist, and I tried to put one into practice myself.  I achieved relatively good results without spending anything but time.  Patience and dedication are the keys to success in a zero-cost method: if you don't have those two qualities, you either need to start working on them or find a job to make money to spend for a <em>proper</em> (but sometimes risky) marketing campaign.<br />
<br />
<br />
<strong>1. Plan your website</strong><br />
<br />
Don't skip this part, because it's the most important step in the whole process: you have to come up with some clever ideas to make your site look unique and original!<br />
<br />
<em>2. Have a look around</em><br />
<br />
<em>?Well, if I were able to do <strong>that</strong> I wouldn't need to promote my site at all, and I wouldn't be reading this article?</em><br />
<br />
This is true to some extent - coming up with an original idea nowadays is difficult if not impossible.  <em>Offering something different</em> or <em>presenting it in a different way</em> can be done, as can offering the same thing <em>but better</em> (that's what Google did).  Once again, you need patience, dedication, and the belief that it is worth it.<br />
 <br />
The best way to decide if it's worth creating a new website is to study your potential competitors, i.e. any other website that deals with the same stuff.  Study the way these websites are created, list their weaknesses and strengths, and after comparing a few of them, start thinking about what <em>you</em> can do to create a <em>better</em> website.<br />
<br />
Then, <em>objectively</em> evaluate your idea and decide if you have the ability to do it, what risks are involved, and how long it would take to create. After all this brainstorming, if you still want to spend time on your project, you can go on; if not, <em>this is your last chance to stop and think about something completely different</em> - it doesn't mean you?re a coward, it just means you are capable of understanding your limits, which is something many people have trouble doing these days.<br />
<br />
<em>4. Create an identity</em><br />
Now it's time to think about a proper <em>identity</em> for your site, and this involves the following steps:<br />
<br />
<ul><br />
<li>Define your objectives and purposes<br />
</li><li>Define the audience of your site<br />
</li><li>Think about a good name for your site<br />
</li><li>Create some graphics and a logo<br />
</li><li>Create slogans and descriptions <br />
</li></ul><br />
<br />
Of course, defining the objectives and purposes of your site is the most important thing on that entire list.  Again, you have to be honest with yourself and not be afraid to admit your limitations: if you find you can't do something you?d like to, try to imagine your site without that particular feature, and if there?s still a hope of success, go ahead.  If not, try looking at your ideas from a different point of view.<br />
<br />
A different point of view could mean a different audience: if you see that there?s absolutely no chance of selling canned pasta to Italians,you might have better luck with the English. Audience is extremely important: it's a factor which influences both the content and the design of your site, as well as the features offered.  Doing something the way <em>you</em> like it doesn't mean other people are going to like it, and for people to want to come to your site, they have to like it!<br />
<br />
Now, think about a good name for your site: it must be easy to remember, be somehow related to what you do, and most importantly, the domain must be available. Check on that before you commit to a particular name, or you might be in for a shock. There are plenty of places on the Net that can tell you if a particular domain with a particular TLD is available[1].<br />
<br />
Next, I think you should come up with a logo, though some people say it's premature to think about graphics at this stage. It's probably true, but I find that having a visual representation of your goal can often be a morale booster that will help you to keep going. <br />
<br />
The last step is a slogan or a description.  This is an important part of creating your site's identity.  It should be honest, yet promising: it has to stick in the consumer's mind.  How you do this is entirely up to you, and it can also be the most time-consuming step of the process - it will probably take you a few tries to come up with something you really like.<br />
<br />
<br />
<em>4. Features, Services and Architecture</em><br />
<br />
Now it's time to do something less idealistic and slightly more practical: you should start listing the features and services your site will offer, and start thinking about how to present them. Don't plan on doing too many things or implementing unnecesssary features on your site - having a forum, a newsletter <em>and</em> a blog on CannedPasta.com could be a bit too much, whereas having a gallery and a Testimonials area could be a much better use of resources. In short, add features because they can be useful, not because it's trendy to offer them.<br />
<br />
After you decide on your features, you have to think about the <em>architecture</em> of your site, or <em>how</em> people are going to find the services you offer on your site.  Menus and navigation bars are a must, but  keep them relatively uncluttered and easy to use: you must be able to grab the visitor?s attention and communicate what you do in the first 10 seconds; then, if the visitor remains on the site for another minute or two, he must be convinced by then that you are selling the best canned pasta he?s ever tried and cheaper than anyone else. This is accomplished mainly by putting links to relevant pages in at the right places: if a visitor can't find your content, he?ll never be persuaded to try your product!<br />
<br />
<br />
<strong>Site Development</strong><br />
<br />
It's now time to start coding your site.  Whether you do it yourself or  have someone do it for you, the web developer should follow some important guidelines when coding the site. I will only touch on them very briefly.<br />
<br />
<em>Make it simple</em> -don't do something unless you have to. The layout of your site must be decided according to the site?s purpose - that's why movie sites have a lot of graphics, Flash[3] and other eye-catching things, and why forums and news sites don't need that stuff at all.  Show your products and describe them with the minimum amount of content; people who want to buy canned pasta normally don't want to know the history of it: they just want to see if it's worth buying it. <br />
<br />
<em>Cleaner is better</em> -the code of your site should be clean,support web standards, and contain no errors. Although code validation[4] is not critical to acquire good placement in search engines, it can help to a certain extent. <br />
<br />
For the sake of code clarity, I normally recommend not using deprecated tags or  and its attributes. Avoiding using tags attributes altogether, if possible: CSS[5] was created for a reason, and that's for making your life easier.  A discussion of CSS is beyond the scope of this article, but I have included a reference link[6] for you to learn more about it.<br />
<br />
<em>Fundamentals of an SEO Strategy</em><br />
<ul><br />
<li>Always provide an ALT attribute for your image </li>(crawlers[7] will process that instead of the image)<br />
<li>Always provide a relevant TITLE attribute to your links<br />
</li><li>Always use properly formatted h1, h2, etc. tags for your titles.<br />
</li><li>The  tag in the  of every page should be different each time and either reflect the page?s content or provide a proper title for it. It should also be one of the first tags on the page.<br />
</li><li>Always remember to provide an icon for your site </li>(favicon[8])<br />
<li>Don't forget a valid robots.txt</li>[9] file in the root directory of your site.<br />
</ul><br />
<br />
<em> Meta Tags</em><br />
Although Google doesn't seem to care about them any more, you should always include some meta tags in every page, particularly for keywords and the site description. Ideally, these should vary according to the page's content, contain not more than 10-15 relevant keywords, and give a brief yet complete description of the page.<br />
<br />
<em> Search Engine Friendly (SEF) URLs</em><br />
Even though all the major search engines can process dynamic URLs correctly, a URL like <a href="http://www.cannedpasta/products/spaghetti.php">http://www.cannedpasta/products/spaghetti.php</a> is much better than something like <a href="http://www.cannedpasta.com/index.php?a=show&amp;cat=1256&amp;id=234.">http://www.cannedpasta.com/index.php?a=show&amp;cat=1256&amp;id=234.</a> The first one will not only be crawled by ANY search engine with no problems at all, but more importantly, users will remember it. If your site is dynamic (as are the majority of websites  these days) and your pages are therefore automatically generated, you could try using mod_rewrite to transform complicated URLs into their simplified but more effective counterparts[10].<br />
<br />
That's all for this part of the article. Next time I?ll discuss the final phases of your site?s zero-cost promotion campaign: website promotion, website maintenance, and what to do once you get things going.<br />
<br />
<br />
<strong>Notes, related links, and further reading:</strong><br />
<br />
[1]You can do so here, for example: <a href="http://www.mydomain.com">http://www.mydomain.com</a><br />
[2]The domain is fictitious and used as an example<br />
[3]Macromedia Flash: <a href=" <a href="http://www.macromedia.com/software/flash/"> <a href="http://www.macromedia.com/software/flash/</a>">http://www.macromedia.com/software/flash/[/url]</a><br />
[4]W3C validator: <a href=" <a href="http://validator.w3.org/">http://validator.w3.org/</a> "> <a href="http://validator.w3.org/">http://validator.w3.org/</a> </a><br />
[5]CSS: <a href=" <a href="http://www.w3.org/Style/CSS/">http://www.w3.org/Style/CSS/</a> "> <a href="http://www.w3.org/Style/CSS/">http://www.w3.org/Style/CSS/</a> </a><br />
[6]Official CSS tutorial: <a href=" <a href="http://www.w3schools.com/css/default.asp">http://www.w3schools.com/css/default.asp</a> "> <a href="http://www.w3schools.com/css/default.asp">http://www.w3schools.com/css/default.asp</a> </a><br />
[7]Web crawler, Wikipedia page: <a href=" <a href="http://en.wikipedia.org/wiki/Web_crawler"> <a href="http://en.wikipedia.org/wiki/Web_crawler</a>">http://en.wikipedia.org/wiki/Web_crawler[/url]</a><br />
[8]Favicon, Wikipedia page: <a href=" <a href="http://en.wikipedia.org/wiki/Favicon"> <a href="http://en.wikipedia.org/wiki/Favicon</a>">http://en.wikipedia.org/wiki/Favicon[/url]</a><br />
[9]Robot.txt tutorial: <a href=" <a href="http://www.searchengineworld.com/robots/robots_tutorial.htm"> <a href="http://www.searchengineworld.com/robots/robots_tutorial.htm</a>">http://www.searchengineworld.com/robots/robots_tutorial.htm[/url]</a><br />
[10]Apache mod_rewrite: <a href=" <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a> "> <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html">http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html</a> </a>]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2005-12-08:/articles/cakephp/</id>
    <title>CakePHP - A 'tasty' solution for PHP programming</title>
    <published>2005-12-08T16:03:39Z</published>
    <updated>2009-09-06T18:10:44Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/cakephp/"/>
    <category term="cakephp" scheme="http://www.h3rald.com/tags/cakephp/"/>
    <category term="review" scheme="http://www.h3rald.com/tags/review/"/>
    <category term="frameworks" scheme="http://www.h3rald.com/tags/frameworks/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <content type="html">
<![CDATA[
Web developers can either love or hate PHP, and one of the criticisms of this easy-to-use programming language which is repeated over and over on IRC, forums and blogs is that "PHP is disorganized".<br />
Is this really true? If so, is there any possible way to write a PHP application in a logical and clean way? Read on...Every web developer has certainly heard of PHP. Some people like it and consider it a powerful and easy-to-use way to create complex websites or web applications, while others are convinced that it is merely a bad copy of Perl.  Opinions are certainly mixed on the matter.<br />
<br />
One thing to keep in mind when reading criticisms of PHP is its origins, as therein lies the crux of the matter. PHP was created as a form interpreter, initially offering only a <em>very limited</em> range of functionality.  Its main purpose was to make life easier for web developers who wanted to do simple tasks,  like manipulating form data.<br />
<br />
People liked the concept - PHP was free and it quickly became popular among developers. More functionality was added and continues to be added with each new release, and PHP is now one of the most popular and powerful programming languages available for web development.It is relatively easy to learn, compared to Perl, ASP, or JSP, and it can be used for almost anything[1].<br />
<br />
The sheer simplicity of the language was most likely the cause of the enormous amount of exploits discovered through the years which earned PHP the label "<em>too dangerous to use in 'proper' applications</em>". The danger, however, lies not in the language itself, but rather in the <em>way</em> developers make use of the language: PHP's simplicity makes writing bad or exploitable code extremely easy. Furthermore, PHP's ability to be placed within any HTML page with the greatest of ease tempted developers to write ever-increasing amounts of 'spaghetti code', which by its very nature is neither organized nor clean code, and certainly does not help a developer learn how to write organized or clean code.<br />
<br />
These problems, however, can be solved.  There are many ways to go about doing this, but the easiest, most effective way is to create a framework[2]. <br />
<br />
<br />
<strong>Bringing Order to Chaos</strong><br />
<br />
After learning some PHP myself, I remember noticing that my applications were growing in a disorganized and uncontrollable manner. Things tended to be added at the last minute, and bugs were fixed and patched 'on the fly' wherever they occurred.  PHP lacked the structure that is present in most other programming languages.  I remember reading the word <em>framework</em> for the first time not too long ago while I was downloading a Windows Update of the .NET framework[3].  That inspired me to start searching the Internet for a 'PHP framework'.  That led me to an interesting blog entry[4] where a solution was proposed - a solution to <em>bring order to chaos</em>:<br />
<br />
<fieldset><blockquote><br />
[...] The answer is simple: create our own class library, some kind of framework, the PHP framework. The similar in many ways to that one which is already well known to Java or .NET programmers. We could set the standards, structure and main guidelines. [...]<br />
</blockquote></fieldset><br />
<br />
That blog post made me think about developing my own framework, until I noticed that there were many projects already in progress, and some in fact completed; the end result being a  fully functional PHP framework.  I read a lot about some of them[5], and abandoned the idea of developing my own, because as a good developer, I believe I should never re-invent the wheel. So I kept looking. I found Pear[6], although that's more a repository of PHP classes with a common standard than a framework, while I was looking for THE solution to developing many types of applications, not merely how to do one thing in particular.<br />
<br />
I came across a very promising project named Prado[7], which  won the latest Zend contest, and was considered the best PHP5 application of the year. It is a masterpiece of coding and PHP5 usage, so I tried to learn it.  I even developed a website with it.<br />
<br />
Prado lets the developer design the application without imposing any ready-made components, but I found its event-driven[8] approach neither easy to learn nor suitable for everyday web applications. I did not like the idea of having to code a reaction to every event (like a click on a button or different phases of page rendering): that is the approach that ASP takes, and at least in that respect, Prado seems to be inspired by the .NET framework.  Event-driven programming is suitable for GUI development and desktop-based interfaces, but not for web applications.<br />
<br />
After trying Prado, I was still unsatisfied, so I once again began my search for a solution to improve my programming. My meanderings took me to Ruby on Rails[9], one of the most recent examples of technology hype on the Net.  At the same time,to a  certain extent, it is also a successful tool. <br />
<br />
<br />
<strong>The Rails Phenomenon</strong><br />
<br />
<fieldset><blockquote><br />
"Rails is a full-stack, open-source web framework in Ruby for writing real-world applications with joy and less code than most frameworks spend doing XML sit-ups."<br />
</blockquote></fieldset><br />
<br />
That sounded like what I was looking for, and  I started reading more about it in the vast and varied help sections[10] available both on and off of the official site. The Rails team did an outstanding job promoting and marketing the framework, and also in providing comprehensive textual documentation (and even video tutorials) to help both beginners as well as experienced programmers get started with it.<br />
<br />
Briefly, Rails uses Ruby's object oriented programming, in conjunction with the MVC pattern and various automated scripts (generators), to help developers program their applications quickly and in a solid and organized way.  However, as that is neither clear nor convincing, let's spend a few moments on the MVC Pattern[11], which will also be useful to understanding the following sections.<br />
<br />
MVC stands for <strong>M</strong>odel <strong>V</strong>iew <strong>C</strong>ontroller: these three words enclose - and this is just a personal opinion - all the wisdom and philosophy of web development, describing - once again, in my opinion - the three most logical parts a web application <em>should</em> be divided into to achieve code robustness, order and power, all at the same time.  Let's look at what each of the component parts mean in detail:<br />
<br />
<ul><br />
[*]<strong>Model</strong>: The model represents the very essence of the <em>information</em> and <em>content</em> of a web application. Imagine this as an object able to gather the information and content of your webpages from a particular resource, such as a database. The model is the only entity able to access resources.<br />
[*]<strong>View</strong>: The view is an attempt to separate the most unstable part of an application: the user front-end. A view is only responsible for presenting the information that the Model gathered. A view does nothing but format the output, and can be compared to a template or report. In all MVC frameworks for web applications, only view files contain (X)HTML code, and mostly only that. They can therefore be changed <em>at any time</em> without having to touch a single line of the business logic of your application.<br />
[*]<strong>Controller</strong>: The controller is the 'brain' of the application. Consider it to be the only part of your program that can 'think' and manage the other parts. Controller files are the only ones able to <em>order</em> the Model to gather information and then pass the information obtained to the view for display.  <br />
</ul> <br />
<br />
Although the MVC seems to make things more complicated, that is part of the objective.  Since one of the advantages (and weaknesses) of PHP was its simplicity, the MVC adds complexity to bring more order and logic to the design process. The three entities are separated for just that reason, and trying to put them together can result in potential disasters, since it causes the whole  pattern to fail.<br />
<br />
Coming back to Rails, I was quite impressed by the features it offered, but there was a small problem: the Ruby programming language itself. I experienced some difficulties in setting up the environment properly, and I also discovered that most standard hosting companies do not offer Ruby hosting plans as standard. Hosting issues aside, I would have had to learn Ruby in order to master Rails, and I really did not have the time for that: I had to develop a website quickly and easily, preferably with languages I already knew.<br />
<br />
After deciding to abandon Rails (for the moment, anyway), I was amazed by the number of projects in other programming languages that try to emulate the famous Ruby framework, to the point of being considered <em>clones</em> or ports of it to another language.  To my knowledge, the <em>Rails disease</em> contaminated the following programming languages:<br />
<ul><br />
<li>PHP</li>[12]<br />
<li>Python</li>[13]<br />
<li>Java </li>[14]<br />
<li>Perl </li>[15]<br />
</ul><br />
<br />
I said <em>disease</em> because Rails developers think that Ruby on Rails was made in Ruby for a reason, namely that Ruby offered some unique features that were not available in other languages.  I will not delve into that topic here; more information is available[16] for those who are interested.  However, suffice it to say that there are some Rails ports in PHP that were immediately attacked because of the fact or legend that the creator of Rails originally wanted to develop his framework in PHP and then switched to Ruby.   Let's examine one of those PHP frameworks in detail.<br />
<br />
<br />
<strong>CakePHP: Just Another Rails Clone?</strong><br />
<br />
I chose to learn CakePHP (or "Cake")[17] mainly because it offered more features than the other two PHP alternatives.  It also  seemed to be a more original and actively developed project.  In particular, I'd like to quote one of CakePHP's developers, from when he introduced the framework in a comment to a blog post[16]: <br />
<br />
<fieldset><blockquote><br />
"While it's difficult to copy Rails in PHP, it's quite possible to write an equivalent system. I like the terseness of Ruby code, but I need the structure that Rails provides, how it makes me organize my code into something sustainable. That's why I'm ripping off Rails in Cake."<br />
</blockquote></fieldset><br />
<br />
Cake's developers (bakers?) are developing their own framework which uses many principles of Ruby on Rails, revisited and re-proposed in an extremely flexible and easy to use PHP tool, rather than simply trying to port Rails to PHP. I also liked the fact that they bothered to choose an original name for their project, unlike others: there are too many "&lt;insert language here&gt;-on-Rails" frameworks, and while the whole "Rails" thing is innovative and catchy the first time, it loses its appeal quickly when people use the word everywhere just because it is "fashionable".<br />
<br />
Quoting from CakePHP's website:<br />
<br />
<fieldset><blockquote><br />
"Cake is a rapid development framework for PHP which uses commonly known design patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. Our primary goal is to provide a structured framework that enables PHP users at all levels to rapidly develop robust web applications, without any loss to flexibility." <br />
</blockquote></fieldset><br />
<br />
That sounds like the Holy Grail for PHP developers, and I must admit I'm quite impressed myself after using it on various little projects, but is it really all true? What are Cake's features? Are there any limitations?<br />
<br />
<br />
<strong>The Ingredients</strong><br />
<br />
So what is Cake?  In the previous sections, I introduced some general concepts and ideas common to Ruby on Rails and CakePHP, but nothing in particular was said about the structure of the framework itself.  Let's now turn to that and discuss it in some detail, particularly as it pertains to Cake.<br />
<br />
The first thing to understand about Cake (and Rails as well) is that one of their aims was to avoid editing long and complex configuration files in order to run the environment.  The approach in this sense is to use <em>conventions</em> over <em>configuration</em>. This may sound terribly restrictive, but in reality it proved  to make things much simpler. After all, I said I wanted to use a framework because I needed a solid structure to base my applications on, not that I needed to be able to create and personalize my own structure and system. Cake uses some simple rules in order to run properly, and the easiest way to explain them is through Cake's directory structure, which represents the skeleton of every CakePHP application.<br />
<br />
<strong><em>/<br />
---app/<br />
------config/<br />
------controllers/<br />
---------components/<br />
------models/<br />
------plugins/<br />
------views/<br />
---------elements/<br />
---------errors/<br />
---------helpers/<br />
---------layouts/<br />
---------pages/<br />
------webroot/<br />
---------css/<br />
---------files/<br />
---------img/<br />
---------js/<br />
</strong>---cake/<br />
------config/<br />
---------inflections/<br />
------docs/<br />
------libs/<br />
---------controller/<br />
---------generator/<br />
---------model/<br />
---------view/<br />
------scripts/<br />
---tmp/<br />
------cache/<br />
------distro/<br />
------logs/<br />
------tests/<br />
---vendors/</em><br />
<br />
I expanded only the first three levels of the tree, although there are more levels in the <em>/cake/</em> directory.  They won't be considered here simply because the <em>/cake/</em> directory contains CakePHP's internal libraries, which normally will not be modified when developing an application.  The <em>/tmp/</em> directory also will not be elaborated upon either, because it is only used to store temporary files. However, the <em>/vendor/</em> directory should contain third party scripts and libraries that you may want to use in your application, but they are not normally integrated with Cake's framework.  95% of your application will reside within the <em>/app/</em> directory, which we therefore need to examine in greater detail.<br />
<br />
<u><em>/config/</em></u><br />
When I said that Cake strives to use conventions over configuration, I really meant it.  This directory does not contain thousands of configuration files, only five very small ones. They represent the only items which <em>might</em> need to be configured. <br />
<br />
[list]<br />
[*]<strong>acl.ini.php</strong>: This file must be edited only if you plan to use Cake's default ACL (access control list) system for your application. It sets permissions for the application, so it should be used to list every group, user, and their respective rights. This can be useful for small sites with a few well known users, but for anything else, you should develop your own ACL or authentication system that relies on a database.   <br />
[*]<strong>core.php</strong>: This file can be edited to change some default options, such as the level of the error messages and notices that the application will output. This comes in very handy while developing an application.<br />
[*]<strong>database.php.default</strong>: This should be renamed to database.php and edited if you plan to use any databases with Cake. The settings are fairly straightforward, and include the type of database used (mysql, postrgres, sqlite, or any other supported by the AdoDB library[18]), username, password and database name.<br />
[*]<strong>paths.php</strong>: Unless you are very particular, you should leave this file alone. It tells Cake where to look for CSS files, images, controllers, etc. If you are planning to adopt Cake's directory structure - which is the most logical option - you can ignore this.<br />
[*]<strong>routes.php</strong>: Following Rails' example, CakePHP features a "routing system" for user-friendly URLs. By default, your URLs will look like this: <em>http://sitename/controller-name/action-name/eventual/action/parameters</em>, which is a really nice way to organize a site, but you may want to change something if you have particular requirements. <br />
[/list]<br />
<br />
<br />
<u><em>Controllers</em></u><br />
As mentioned previously, a controller represents the "brain" of the MVC pattern, the part which controls what the other parts are doing. Imagine a controller like a section of your site: its name will be present on the address bar, and each of these sections will have a file named &lt;something&gt;_controller.php, and will also contain a class named SomethingController that extends the AppController class. This class will  have some methods that correspond to some standard actions like <em>index</em> (the default action called when you access the <a href="http://sitename/controller/">http://sitename/controller/</a> page) or other user-defined ones like <em>add</em> or <em>list</em> or <em>admin</em>, depending on the application. As a general rule, you want to add any 'business logic' you want to implement in your application in controllers - for example, calculations or a database query that produces a result. <em>Then</em> once all the mess is done, the result (usually an array or a variable) is passed to the view (see <em>views</em> below). <br />
 <br />
If this is starting to sound too technical for you, I recommend reading a tutorial[19] available on the CakePHP website about creating a simple blog application. The tutorial will explain most of Cake's basics, including how to pass a variable from a Controller to the corresponding view <em>($this-set('variableNameInView', $variable))</em> and other useful things.<br />
<br />
Recently <em>Components</em> have been added to CakePHP, and quoting from the corresponding wiki page[20]:<br />
<fieldset><blockquote><br />
"Components are the preferred way to provide additional functionality to your controller. To make a component available you would add var $component = array('myComponent') inside of your controller's definition, add your file to the /app/controllers/components, name your class MyComponent, and create your methods."<br />
</blockquote></fieldset><br />
<br />
<br />
<u><em>Models</em></u><br />
A model is an object able to access the database. In Cake's terms, that is any class extending the AppModel class. That class is directly under the <em>/cake/</em> directory (along with the previously mentioned AppController class), and can be moved to the <em>/app/</em> directory and modified if you want to add some particular site-wide behavior to it which will be inherited by all models extending it.<br />
<br />
In even simpler terms, you need to create a Model class for every table you're planning to use in your database. A convention in Cake says that database table names should be plural and that the corresponding model should be singular. If you use a table named 'mice', your model should be named 'mouse': Cake is smart enough to understand irregular plurals through an <em>Inflector</em> class.<br />
<br />
Creating a model class for basic use is trivial:<br />
<br />
<br />
class Post extends AppModel<br />
{<br />
    var $name = 'Post';<br />
}<br />
<br />
<br />
Then you'll be able to access the model (and therefore the database) from a controller via simple instructions like $this-&gt;Post-&gt;findAll(). This instruction will query the database and return all records within the Posts table in your database.  You can also perform more complex operations, and also specify SQL queries to execute, if you need to, but remeber that models can only be accessed through controllers! If you need some information stored in your database to be displayed on a view, execute the query from the controller and pass it to the view as per the MVC pattern.  It can prevent you from cluttering views with business logic and thereby making code updates much harder.<br />
<br />
<br />
<u><em>Views</em></u><br />
Views are used to present information gathered with a model and a controller to the public. They are mostly HTML pages with some PHP tags in them, prints of variables and maybe some <em>foreach</em> loops. Nothing more than that should be used in a view!<br />
<br />
Views must be placed in this directory and obey the following conventions:<br />
<br />
1. They must be named after a controller's action to allow the controller to refer to a particular view automatically. The same view can be used by multiple controllers, but it must be either set manually or through a layout (see below).<br />
2. Views referring to an action of a particular controller must be placed under a subfolder named after the controller.<br />
3. All views must have a .thtml extension.<br />
<br />
Any site-wide view, like the site's template, must be placed under the <em>layouts</em> subfolder. In particular, the default.thtml file in the folder represents the global template for your application: page titles and specific pages (views) will be invoked automatically by using $title_for_layout and $content_for_layout respectively.<br />
<br />
Similarly to what was said about components, <em>helpers</em> can be used to extend views functionalities[20]:<br />
<br />
<fieldset><blockquote><br />
"Helpers are all about the view. You know about the helpers in Cake, but you need a little bit more. You want to have your own methods to display formatted info. To achieve this, you need to add var $helpers = array('myHelper').<br />
<br />
Now, throw your myhelper.php file into the /app/views/helpers/, create the class MyHelper, and $myHelper is available in the view." <br />
</blockquote></fieldset>   <br />
<br />
Cake comes with some very useful default helpers to create links and HTML tags, import JavaScript, create forms, and use AJAX code easily. Unlike most other frameworks, Cake neither has nor uses a third party template engine (like Smarty[21]) for views, but helpers can be used to achieve similar results more quickly than an engine can.<br />
<br />
<br />
<u><em>Plugins</em></u><br />
<br />
Plugins are user-developed enhancements for Cake. Unlike the files placed under the <em>vendor</em> directory, a plugin is an application specifically made to be used within the CakePHP environment. At the moment this feature is still under development.<br />
<br />
<u><em>Webroot</em></u><br />
<br />
If you read carefully what I wrote above about routes, you might be wondering if <em>every</em> page must have a controller and a view in order to be displayed properly. What about images, JavaScript and CSS files? The answer is this directory: everything you place here will not be seen as part of the MVC-based environment; CSS files can be stored in the <em>/css</em> folder, Javascript under <em>/js</em>, and so on. Additionally, some helpers can provide a easier way to access or display images, scripts, CSS, etc.<br />
<br />
<br />
<u><em>Other Features</em></u><br />
Cake offers even more than this; the latest releases have introduced a few more Rails-inspired features:<br />
<br />
[list]<br />
[*]<strong>Scaffolding</strong>: Do you want to test your application without spending time writing all the CRUD (Create, Read, Update, Delete) code? That's where the concept of scaffolding comes in:  by setting a few variables in the right places[22], Cake will generate basic mechanisms to add, edit, list, and delete records in your database, along with all the associated view files. You won't have to code a single form, as everything will be generated automatically by the framework according to SQL field types.<br />
[*]<strong>Bake</strong>: Another Rails-inspired feature revisited in PHP. Rails uses a set of scripts and in particular the <em>rake</em> utility to instantaneously create the foundation for a Rails application with scaffolds already in place.  CakePHP offers the same functionality through the <em>bake</em> utility, which is currently available as either a batch file or a PHP script.<br />
[*]<strong>ACL</strong>: As previously mentioned, Cake comes with a ready-made Access Control List (ACL) system, which can be extended and used to restrict particular areas of a Cake application to certain users or user groups.<br />
[*]<strong>Compatibility</strong>: CakePHP is fully compatible with both PHP and PHP5.<br />
[/list]<br />
<br />
<br />
<strong>Meet the Bakers</strong><br />
<br />
After reading all these things about CakePHP and its framework, you may have some questions, or be curious about some aspect of the project. PHPNut and gwoo, two of CakePHP's creators and lead developers, offered to answer some questions exclusively for zZine readers. This interview took place on Oct. 26th, 2005, in #dev-cakephp on irc.freenode.org.<br />
<br />
<em><u>h3rald</u>:</em> Thanks to both of you for allowing me to interview you about your project, CakePHP. Where did the name come from, anyway?<br />
<br />
<em>PHPnut:</em> The original project was started by Michal Tatarynowicz aka Pies (hence the name), and when I saw his release, last March, I decided to contact him.  I told him that the company I own supports projects like Cake, and also that I was in the process of developing something along the same lines. <br />
<br />
<em><u>h3raLd</u>:</em> Is Cake released under the GPL? How many developers are helping out?<br />
<br />
<em>gwoo:</em> Cake is released under the MIT license, and the development team is composed of me and PHPnut, plus four other contributors. Then there's the Documentation Team, currently 3-5 people. Documentation has to follow the releases, so it usually lags behind a bit: we made so many modifications in the recent release that the Doc Team has a lot to catch up on, but it's getting there.<br />
<br />
<em>PHPnut:</em> With this release you will see that the docs are going to be much better. The code is very stable now, and hopefully very little changes on that.<br />
<br />
<em><u>h3raLd</u>:</em> Some people, at first glance, may think that Cake is a PHP port of Ruby on Rails. How true is that? What are the differences and similarities between these two frameworks?<br />
<br />
<em>PHPnut:</em> Cake started as a port, but has evolved into something more: we discussed using the concepts that RoR offered and including them in a framework for users of PHP.  I have used PHP for a number of years, and  I am comfortable with it; this is where my passion is, and I think people who use Cake have those same passions as we developers do.<br />
<br />
<em><u>h3raLd</u>:</em> I read once that Rails was developed in Ruby because only Ruby can offer certain functionalities and features...<br />
<br />
<em>gwoo:</em> I would disagree, and I think that is proven in what we have done: sure RoR has a built in server and some other nice things, but PHP is everywhere.<br />
<br />
<em><u>h3raLd</u>:</em> Some developers, especially Perl programmers, tend to consider PHP an "inferior" language sometimes.  What do you think of that?<br />
<br />
<em>PHPnut:</em> My name says what I think about them all.<br />
<br />
<em>gwoo:</em> PHP is a web programming language; that's what it was designed for, and that's what it does best: It all boils down to what you are comfortable with.<br />
<br />
<em><u>h3raLd</u>:</em> Did you try any other PHP frameworks, MVC-based (Mojavi, for example), or event-driven, like Prado? What do you think about them? In what ways can Cake be better or worse?<br />
<br />
<em>gwoo:</em> They are all so complex, in my opinion, and I tried nearly all of them. Cake breaks apart the MVC and handle the CRUD in a logical way, and Cake syntax is super easy to learn.<br />
<br />
<em><u>h3raLd</u>:</em> Ruby on Rails has been ported to various languages, including Java and Python. There are three PHP frameworks inspired by the famous Ruby project: Biscuit, PHP on Tracks and CakePHP.  What do you think of that? Any chance of a merge? Did you have a look at them?<br />
<br />
<em>gwoo:</em> You forgot Symfony[27], a PHP5-only port: I tried it but it seems much harder to learn than Cake.<br />
<br />
<em>PHPnut:</em> I could be wrong, but I think these other projects are behind us in ease of use, in what the framework is capable of doing, and in  features, not to mention community support.<br />
<br />
<em>gwoo:</em> I tried all of the PHP ports of Ruby on Rails and none of them has the features, the community,or a lexicon as good as Cake's.<br />
<br />
<em><u>h3raLd</u>:</em> Why don't you consider CakePHP a port? In what way is it evolving from Rails?<br />
<br />
<em>PHPnut:</em> Rails and CakePHP share a lot: MVC pattern, Active Record pattern...but we're not strictly following Rails, and we're able to think by ourselves. Recently we changed the directory structure, and in my opinion our is more functional than the Ruby on Rails one.<br />
<br />
<em><u>h3raLd</u>:</em> What can Cake be used for? What kind of projects? Are there any limitations?<br />
<br />
<em>gwoo:</em> Personally I think that Cake is the most extensible framework out there for PHP: with components, helpers and vendor access you can do anything you want!<br />
<br />
<em>PHPnut:</em> We are limited only by what a web server (generally Apache, but IIS seems to work as well) and a database can do. We may be limited by PHP itself, but we twist that in our own little sick ways sometimes.<br />
<br />
<em><u>h3raLd</u>:</em> Any thought about AJAX? I saw some nice demos made with Cake.   What do you think of this new trend in web development? Some people consider it the future, while others are concerned about compatibility, and still others are relatively indifferent to it.  What about you?<br />
<br />
<em>gwoo:</em> AJAX can be very useful in creating an application, but should not be overused. People have become very comfortable with how the Web works:i f you start doing tons of drag and drop and no refreshes, users will feel lost in how to operate the site.<br />
<br />
<em><u>h3raLd</u>:</em> Thank you very much for your time, both of you. Is there anything you'd like to add to this interview? Something you'd like to say to users interested in trying out Cake?<br />
<br />
<em>PHPnut:</em> Come and enjoy: we are here to help...<br />
<br />
<em>gwoo:</em> ...And plan to be here for a very long time!<br />
<br />
<br />
<strong>Let's cook...</strong><br />
<br />
One of the most positive things about CakePHP is that even though it is a fairly new project (most of the code is 100% useable already,but  they still consider the projectto be in the 'alpha' stage), it's maintained by many dedicated developers and PHP enthusiasts. I was amazed to see how the whole documentation evolves and is quite literally updatedon a daily basis. <br />
Anybody can contribute to the framework or simply test it and share their experiences.<br />
<br />
<u><em>CakePHP Wiki</em></u><br />
<br />
Anybody can register an account for free and contribute tutorials and documentation to the new CakePHP Wiki[23]. This is currently the most up-to-date source for documentation files and tutorials.<br />
<br />
<u><em>CakePHP User Group</em></u><br />
<br />
If you need assistance or you want to contact the Cake developers or other Cake users, you can post a message on their Google User Group[24]: people will reply with useful comments, usually on the same day, and the developers <em>do</em> listen to user suggestions.<br />
<br />
<u><em>CakePHP IRC Channel</em></u><br />
<br />
If you want to offer (or receive) real-time assistance, feel free to join #cakephp on FreeNode (irc.freenode.org). I went there disguised as a total newbie (it wasn't much of a stretch) and they helped me a lot, explaining basic concepts of the framework and pointing me to the right documentation files.<br />
<br />
<u><em>CakePHP Development</em></u><br />
<br />
Experienced PHP developers are more than welcome to contribute to the project. People may be accepted to the core development team if they have sufficient knowledge and spare time, or alternatively,components or code can be submitted through the newly created CakeForge[24].  <br />
<br />
<br />
<strong>...Or Just Eat</strong> [small]<em> by Marc Abramowitz</em>[/small]<br />
<br />
If you don't feel ready to contribute and you'd like to try out the framework first, it can be downloaded directly from the CakePHP site[25] as either a  <em>release</em> or a <em>nightly</em> build: the zip file is less than 300KB.<br />
<br />
I wanted to include a <em>success story</em> written by Marc Abramowitz, an experienced PHP programmer who decided to adopt CakePHP as a framework to use in a production environment: he persuaded his colleagues to use it and they all seem happy with it.  He writes:<br />
<br />
<em>For the past few years, I've done quite a bit of work in PHP, working on production code that runs on a very high traffic web site. PHP has served us well, as it is easy to write and read, quite efficient, and easy to integrate with existing C++ code as the site grew.<br />
<br />
Lately, there has been a lot of buzz in the web development community about Ruby on Rails. Like many others, I took some interest in Ruby on Rails because I was intrigued by the apparent power and elegance of Ruby and because I wondered if a Model/View/Controller (MVC) framework like Rails would help enforce a more consistent code structure that would make the code easier to understand and maintain. Additionally, I wondered if an MVC framework would enable very rapid prototyping.<br />
<br />
Some people are very wary of frameworks that impose structure, as they like to have the freedom to do things however they want. However, there is a tradeoff between structure and flexibility. If you're working on a small team or a relatively small project, then you may not find structure to be very helpful; you may even find that it gets in your way. <br />
<br />
However, as teams and projects get larger, structure becomes more and more valuable, as it enforces consistent patterns of how to do things and rather than being something that limits, it in fact liberates, because it abstracts away the small details and allows us to therefore concentrate on the larger problem. Think of the lines that are painted on our roadways - although they add structure, we don't find them to be limiting. On the contrary, they help us to drive without worrying about crashing into each other at every moment - they free us from being concerned with small details so that we can concentrate on getting where we're going.<br />
<br />
Rapid prototyping appeals to me, because I find it helps me to better present my ideas for new apps and features. A mockup can only go so far - there is no substitute for a working prototype. When clients get their hands on a functional prototype, they get a better idea of what is possible and it forces them to clarify their requirements for the product. This results in a better dialogue between the developer and the client, which leads to better upfront decisions, more stable requirements, less stress, and a better product.<br />
<br />
So, Rails appealed to me not only because of the potentially valuable structure that it could add, but also because it could enable rapid prototyping. However, I knew that there was no chance of Rails being used for production code in my organization, because we run some very high traffic web sites that require the utmost in efficiency.  We are also by and large a PHP shop.<br />
<br />
However, when my manager approached me and asked me to develop a database-backed internal tool, I thought of Rails again.  I then considered the fact that I would probably someday have to hand this app off to someone else, and that someone would probably know PHP but not Ruby. Heck, even I had several years of experience with PHP (including writing some PHP extensions) but I had only done a little bit of reading about Ruby, and I also had no practical experience with it.<br />
<br />
Furthermore, with PHP I had access to a large number of PHP extensions that wrapped various internal libraries. So PHP was the natural choice. Ideally, I wanted to use PHP with a Rails-like MVC framework that would facilitate rapid development, and this is what led me to CakePHP.<br />
<br />
I began by downloading CakePHP 0.9.2 and following the sample tutorial that walks you through creating a simple blog application (note that at the time of this writing, the current version of Cake is now 0.10.0.1076, so some of the details of using Cake have changed). I was pleased to find that the process was quite similar to the process for Rails. One difference that I noted was that Rails tutorials always emphasize using scripts to generate models, controller, and scaffolds, whereas the Cake tutorial walked me through explicitly writing out all the code. I noticed that the Cake download came with a script called "bake" which looked like something that could potentially do some of the code generation, but since it wasn't mentioned in the tutorial, I chose not to use it.<br />
<br />
The process of creating a first application using the tutorial was quite easy. Here are the steps in brief (consult the tutorial for more details):<br />
<br />
1. Create the database table. Cake requires tables to have some extra<br />
fields:<br />
  - id, an auto_increment primary key<br />
  - created, a datetime<br />
  - updated, a datetime<br />
2. Configure Cake to access the database by editing the config/database.php file<br />
3. Create a model class which extends AppModel (a Cake provided class)<br />
4. Create a controller class which extends AppController (a Cake provided class) and write one or more controller methods<br />
5. Create a view which is a PHP file with a .thtml extension and is meant to be mostly HTML with very little embedded PHP - typically just echoing of variables and some simple control structures like [i]foreach</em>.<br />
Cake also provides some simple convenience methods that write out certain HTML constructs for you.<br />
<br />
That's it! That alone is enough to create a basic but functional application. The tutorial goes on to show you how to add additional functionality to the blogging app. After that there's a shorter, more advanced tutorial that shows you how to add a few more things to the blogging app.<br />
<br />
Once I had gotten comfortable with Cake by following the tutorial, I proceeded to write my own application. Getting started was easy - I followed the same steps as in the tutorial to create my first table, model, controller, and views, then my second table, model, controller, and views. Then my app got a bit more complicated. I needed to have many-to-many relations and more elaborate queries than the default ones that Cake provides. I began to worry that Cake would break down here. I had heard people grumble that MVC frameworks like Rails and Cake were great for little toy apps that only do CRUD (Create, Read, Update, Delete), but that they couldn't handle complex queries using joins and the like. I poked around in the Cake source code and was pleased to find that there were nice lower level methods that allowed me to bypass the Cake defaults and do whatever custom queries I liked. For example, I wrote something like this in one of my models:<br />
<br />
function index(){<br />
           return $this-findBySql(<br />
               "SELECT id, title, AVG(rating) avg_rating, MIN(rating) min_rating, MAX(rating) max_rating, COUNT(rating) num_ratings " .<br />
               "FROM ideas LEFT JOIN ratings ON ideas.id =<br />
ratings.skill_id " .<br />
               "GROUP BY id " .<br />
               "ORDER BY title");<br />
       }<br />
<br />
<br />
So what I have is a model that does <em>not</em> have a one-to-one mapping with a single table. It actually retrieves data from more than one table.<br />
<br />
Over time, I picked up a few more Cake concepts. For example, at some point we decided that every page of the app would have a similar look and feel with a particular masthead and logo, and all the pages in one section of the site would show tabs for all of the various views with the currently selected tab highlighted. At first, I just used the same code at the top of each of my views to display the masthead, logo, and tabs. This, of course, became a pain when I needed to change the layout, since I needed to make the same change in several different views.<br />
<br />
Then one day I realized that Cake had a concept of layouts, which are high level templates in  <em>app/views/layouts</em> that define the basic structure of pages.  The individual views are just content that gets embedded in these high level layout templates. So I took the common masthead and logo, put it in my default layout, and removed it from the individual views. Now when I wanted to change the look of the masthead, I only had to do it in one place. For the tabs, I discovered the concept of elements. I placed the code for my tabs in <em>apps/views/elements/tabs.thtml</em>.  Then the tabs could be displayed in any template using:<br />
<br />
&lt;?php echo $this-renderElement('tabs') ?<br />
<br />
Rather than stick the above statement in all of the many pages that were supposed to display tabs, I created a new layout in <em>apps/views/layouts/tabbed.thtml</em> (which uses renderElement to render the tabs). Then I used<br />
<br />
$this-layout = "tabbed"<br />
<br />
in the controller to tell it to use the tabbed layout rather than the default (non-tabbed) layout.<br />
<br />
After a couple of days of work on this application, it was time to demo it to the VP, who was very impressed with what I was able to accomplish in such a short period of time. It was brought up that before I took on the project they had asked some other folks how long it would take them to build it in Java and they had said that it would take on the order of months what I had built in a couple of days. Morals of the story:<br />
<br />
1. Cake is very lightweight and productive<br />
2. Cake might be very beneficial to your career<br />
<br />
Eventually, I was assigned to another project and my manager wanted me to transition my Cake project to another engineer, who was experienced with PHP but not with Cake. I sat down with the new engineer and in about 20 or 30 minutes of explanation and walking him through the code,<br />
he felt ready to code. Not only did he feel that he knew enough to start working with the application, I could tell from the smile on his face that he was very impressed by the power and succinctness of Cake, which was the  same reaction that I initially had. After a couple of days, I checked back with him and he had made a remarkable amount of progress on the application - there were a ton of new pages and features.<br />
<br />
So you see, Cake is a very productive environment. For a very small investment in the initial learning curve, you can get a significant increase in productivity.<br />
[/i]<br />
<br />
<strong>...And the icing?</strong><br />
<br />
So that's what CakePHP is about. The project may only have just entered alpha stage, but the code is already very stable and useable, as PHPnut, gwoo and Marc said.  So what's going to be included in the beta and stable releases? I researched a bit and asked the developers, and here's how Cake will probably evolve in the following months:<br />
<br />
<ul><br />
<li>Cake's built-in </li><strong>data-validation</strong> capabilities will be extended. A validator class - which already exists, by the way - will be extended to include more data types and expressions to be validated before being stored in a database. <br />
<li>A new default </li><strong>ACL system</strong> will be included and will support database access and .ini files as well. <br />
<li> The </li><strong>AJAX</strong> helper class and AJAX support will be enhanced, featuring unobtrusive JavaScript and ALA behavior[28].<br />
<li> </li><strong>Multiple applications</strong> with the same core files. In the future developers will be able to create their own Cake application which could be placed in the app/plugins directory and be seamlessly integrated and auto-linked to other Cake applications.<br />
</ul>   <br />
<br />
After learning all this about Cake and after trying it out myself, I really think that I have found the solution to all of my PHP web development problems. CakePHP can really help PHP developers a lot if properly used and understood.  Still not convinced? Just try it out then, will you?[17]<br />
<br />
<br />
<strong>Notes and Related Resources</strong><br />
<br />
Special thanks to:<br />
<ul><br />
[*]<strong>Larry E. Masters aka <em>PhpNut</em></strong> and  Garrett J. Woodworth <strong>gwoo</strong> for providing all the answers to my questions and contributing to create such a wonderful tool for the PHP community.<br />
[*]<strong>Marc Abramowitz</strong> for sharing his experiences with the CakePHP framework and providing the content for the '...let's eat' section.<br />
</ul><br />
<br />
[small]<br />
[1] PHP functions reference, <a href="http://www.php.net/manual/en/funcref.php">http://www.php.net/manual/en/funcref.php</a><br />
[2] Framework, Wikipedia Page - <a href="http://en.wikipedia.org/wiki/Framework">http://en.wikipedia.org/wiki/Framework</a><br />
[3] .NET framework overview - <a href="http://msdn.microsoft.com/netframework/technologyinfo/default.aspx">http://msdn.microsoft.com/netframework/technologyinfo/default.aspx</a><br />
[4] "PHP Framework", delorian's blog, PHP Community - <a href="http://www.phpcommunity.org/node/100">http://www.phpcommunity.org/node/100</a><br />
[5]Some popular PHP frameworks: Mojavi (<a href="http://www.mojavi.org/">http://www.mojavi.org/</a>), phpMVC (<a href="http://www.phpmvc.net/">http://www.phpmvc.net/</a>), BlueShoes (<a href="http://www.blueshoes.org/">http://www.blueshoes.org/</a>), Seagull (<a href="http://seagull.phpkitchen.com/">http://seagull.phpkitchen.com/</a>).<br />
[6] PEAR - <a href="http://pear.php.net/">http://pear.php.net/</a><br />
[7] Prado - PHP Rapid Application Development Object-Oriented, <a href="http://www.xisc.com/">http://www.xisc.com/</a><br />
[8] Event Driven Programming, Wikipedia Page -  <a href="http://en.wikipedia.org/w/index.php?title=Event_driven_programming">http://en.wikipedia.org/w/index.php?title=Event_driven_programming</a><br />
[9] Ruby on Rails, Official Page - <a href="http://www.rubyonrails.org/">http://www.rubyonrails.org/</a><br />
[10] Ruby on Rails, Doumentation - <a href="http://documentation.rubyonrails.com/">http://documentation.rubyonrails.com/</a><br />
[11] Model View Controller, Wikipedia Page - <a href="http://en.wikipedia.org/w/index.php?title=Model-View-Controller">http://en.wikipedia.org/w/index.php?title=Model-View-Controller</a><br />
[12] PHP frameworks inspired by Rails: <a href="http://phpontrax.com/">http://phpontrax.com/</a>, <a href="http://flinn.activeintra.net/biscuit/">http://flinn.activeintra.net/biscuit/</a>, <a href="http://www.cakephp.org/">http://www.cakephp.org/</a><br />
[13]Python frameworks inspired by Rails: <a href="http://fanery.sourceforge.net/">http://fanery.sourceforge.net/</a>, <a href="http://fanery.sourceforge.net/">http://fanery.sourceforge.net/</a>, <a href="http://subway.python-hosting.com/">http://subway.python-hosting.com/</a><br />
[14]Java framework inspired by Rails: <a href="https://trails.dev.java.net/">https://trails.dev.java.net/</a><br />
[15]Perl frameworks inspired by Rails:<br />
<a href="http://search.cpan.org/dist/Catalyst/lib/Catalyst/Manual/Intro.pod">http://search.cpan.org/dist/Catalyst/lib/Catalyst/Manual/Intro.pod</a>, <a href="http://perlonrails.org/index.php/Main_Page">http://perlonrails.org/index.php/Main_Page</a> <br />
[16] "Rails Clones: Blood suckers or useful drones?", RedHanded - <a href="http://redhanded.hobix.com/cult/railsClonesBloodsuckersOrUsefulDrones.html">http://redhanded.hobix.com/cult/railsClonesBloodsuckersOrUsefulDrones.html</a><br />
[17] CakePHP - Rails-inpired PHP framework, <a href="http://www.cakephp.org/">http://www.cakephp.org/</a><br />
[18] AdoDB, PHP Database Abstraction Layer - <a href="http://adodb.sourceforge.net/">http://adodb.sourceforge.net/</a><br />
[19] CakePHP blog tutorial - <a href="http://wiki.cakephp.org/tutorials:blog_tutorial_-_1">http://wiki.cakephp.org/tutorials:blog_tutorial_-_1</a><br />
[20] Extending CakePHP -  <a href="http://wiki.cakephp.org/tutorials:extending_cake">http://wiki.cakephp.org/tutorials:extending_cake</a><br />
[21] Smarty, PHP Template Engine - <a href="http://smarty.php.net/">http://smarty.php.net/</a><br />
[22] Scaffolding a Blog, CakePHP Wiki - <a href="http://wiki.cakephp.org/tutorials:scaffolding_a_blog">http://wiki.cakephp.org/tutorials:scaffolding_a_blog</a><br />
[23] CakePHP Wiki - <a href="http://wiki.cakephp.org/">http://wiki.cakephp.org/</a><br />
[24] CakePHP Google User Group - <a href="http://groups.google.com/group/cake-php">http://groups.google.com/group/cake-php</a><br />
[25] CakeForge - <a href="http://cakeforge.org/">http://cakeforge.org/</a><br />
[26] CakePHP Downloads Page - <a href="http://cakephp.org/downloads/">http://cakephp.org/downloads/</a><br />
[27] Simfony, PHP5 framework - <a href="http://www.symfony-project.com/">http://www.symfony-project.com/</a><br />
[28] ALA behavior - <a href="http://bennolan.com/behaviour/">http://bennolan.com/behaviour/</a><br />
[/small]]]>
    </content>
  </entry>
  <entry>
    <id>tag:www.h3rald.com,2005-06-28:/articles/server-packages/</id>
    <title>Easy-to-install server packages</title>
    <published>2005-06-28T20:12:19Z</published>
    <updated>2009-09-06T18:10:43Z</updated>
    <link rel="alternate" href="http://www.h3rald.com/articles/server-packages/"/>
    <category term="review" scheme="http://www.h3rald.com/tags/review/"/>
    <category term="webdevelopment" scheme="http://www.h3rald.com/tags/webdevelopment/"/>
    <category term="php" scheme="http://www.h3rald.com/tags/php/"/>
    <category term="databases" scheme="http://www.h3rald.com/tags/databases/"/>
    <content type="html">
<![CDATA[
The first and most obvious difference between, say, a C++ programmer and a PHP developer is that the PHP developer needs a server with PHP support up and running somewhere in order to "show" others that the application is working. This normally means that a PHP developer must either have remote access to a server, or have one set up on his machine. Installing and configuring a server can be tricky sometimes, especially if you want to configure it "properly", but in some cases - for Linux/BSD users mainly - there are some pre-configured servers you can download and install. <br />
<br />
I won't examine all these methods in this article, but I'll describe three alternatives for installing and run a webserver on windows in 10 minutes or less.<br />
<br />
<strong>Preliminary considerations</strong><br />
Let's assume that you just want to have a server set up on your computer for <em>internal use</em> only, for testing purposes. That means that you wouldn't need to be concerned about "security" or similar issues - you just want to be able to run your PHP scripts and access your database(s) quickly and easily. <br />
<br />
As I said earlier, Linux users would probably opt for some package available for their favourite distros - they would only have to download and install an .rpm or .deb package for (presumably) Apache httpd, PHP and MySQL, and just use a basic configuration. There are other tools around which can help if you want to compile or configure Apache, but that is beyond the scope of this article.<br />
<br />
Let's just focus on Windows users, then. Normally they like things that are easy to install and can be configured in a few minutes <em>maximum</em> or not at all. Finally, let's assume that as a Windows user, you don't want to spend more money for a new operating system with a bundled server, like Windows 2003, because you can use <a href="http://www.apache.org">Apache</a> on Windows as well, for free.   Having said this, I actually found 3 possible solutions that are handy for PHP (or Perl) developers who don't want to spend time learning how to configure a server. There are people like that, including myself to some extent.<br />
<br />
<br />
<strong>WAMPserver</strong><br />
<a href="http://www.wampserver.com">WAMP</a> stands for "Windows Apache MySQL PHP", and I must say that this product happens to be my choice. The current version, available at the time of writing, offers:<br />
<br />
- PHP 5.0.4<br />
- Apache 1.3.33<br />
- MySQL 4.1.10a<br />
- phpMyadmin 2.6.1-pl3<br />
- SQLitemanager 1.0.4<br />
<br />
This is basically a fully working PHP5 environment, with other tools like phpMyadmin to administer your MySQL database even more easily (more laziness!), and, if you're into the new functionalities of PHP5, it also comes with sqlitemanager, a php application similar to phpMyAdmin but for sqlite databases, which are supported by default in PHP5.<br />
You download it, you start the installation program, and it's DONE. That's it. In 5 minutes you have your own little apache/php/mysql(ite) environment up and running and you can start showing off your sites to your friends and co-workers right away.<br />
<br />
The program also installs two services which can be run at startup, a little icon in the system tray to access all the tools and, of course, <a href="http://localhost">http://localhost</a> in your favourite browser.<br />
<br />
If all this is still not enough for you, and you want more things more easily, you can install addons to set up PHP4 (and seamlessly switch between the two with a single click!), Perl, Zend Accelerator, and so forth.<br />
<br />
<br />
<strong>EasyPHP</strong><br />
The second suite I will briefly describe is <a href="http://www.easyphp.org">EasyPHP</a>. This is a French project (like the previous one, actually), which offers PHP4, MySQL and Apache, plus phpMyAdmin to administer the MySQL databases. However, it doesn't offer PHP5 support yet (so it's not my favourite) and thus there's no sqlite support either.<br />
<br />
Apart from that, it works exactly like WAMP: you download it, you install it, and it's done. Services are installed and you have - again - your little icon on the system tray to access all its functions and tools. It works well, but it doesn't seem to have any add-ons available like WAMP does.<br />
<br />
<strong>XAMPP</strong><br />
This is by far the most complete distribution of the three I am focusing on. This project is developed by <a href="http://www.apachefriends.org">Apache Friends</a> and has a lot of features and flavours. XAMPP currently includes:<br />
<br />
- Apache HTTPD 2.0.54<br />
- MySQL 4.1.12<br />
- PHP 5.0.4 + 4.3.11 + PEAR + Switch<br />
- MiniPerl 5.8.6<br />
- Openssl 0.9.7g<br />
- PHPMyAdmin 2.6.2-pl1<br />
- XAMPP Control Panel 1.0<br />
- eAccelerator 0.9.3<br />
- Webalizer 2.01-10<br />
- Mercury Mail Transport System for Win32 and NetWare Systems v4.01a<br />
- FileZilla FTP Server 0.9.8a<br />
- SQLite 2.8.15<br />
- ADODB 4.63<br />
- Zend Optimizer 2.5.7<br />
- XAMPP Security for Windows 98, 2000, XP<br />
<br />
Honestly, you can't ask for more! If by chance you want to run this suite on other platforms, there's a version for Mac OS X, Solaris, and even Linux.<br />
<br />
The installation method for XAMPP is slightly more difficult than the other suites - you actually have to download and unzip it in a folder of your choice. Then you're off and running.<br />
<br />
Unfortunately (or fortunately), there's no icon on the system tray, so you need to actually access <a href="http://localhost">http://localhost</a> to get a list of services and tools. It also doesn't come with sqlitemanager, but you can download it and install it in the documents folder (like I did).<br />
<br />
I actually use XAMPP - the "lite" edition, which is smaller and has less features - for my USB drive. Since it doesn't require any services to be installed in order to run, you can simply copy it onto a USB stick and run it from there!<br />
<br />
<strong>Conclusion</strong><br />
I'm quite impressed by all of the server packages I reviewed; WAMP and XAMPP in particular. I can now carry around my websites and applications and instantly run them or show them to anyone who has a computer with a USB port.<br />
<br />
As I said in the beginning, these programs are NOT meant to be used in a production environment or to be accessed publicly, therefore, security is not a consideration here. In my opinion, they are simply excellent for testing purposes, and for now, that's what I need them for.]]>
    </content>
  </entry>
</feed>

