<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AVNet Labs &#187; PHP</title>
	<atom:link href="http://avnetlabs.com/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://avnetlabs.com</link>
	<description>Accessible web development</description>
	<lastBuildDate>Mon, 04 Jan 2010 21:28:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Jazz up your phpunit test results</title>
		<link>http://avnetlabs.com/php/jazz-up-your-phpunit-test-results</link>
		<comments>http://avnetlabs.com/php/jazz-up-your-phpunit-test-results#comments</comments>
		<pubDate>Sun, 01 Feb 2009 14:07:34 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/jazz-up-your-phpunit-test-results</guid>
		<description><![CDATA[I use RedGreen when working on rails projects and have gotten used to the visual feedback I get when tests pass or fail. It has definitely helped with my Red-Green-Refactor flow.
I just found out phpunit supports colors in tests and it&#8217;s built-in as well. No gem installation required. Sweet!
Turning on colours is done either with [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://on-ruby.blogspot.com/2006/05/red-and-green-for-ruby.html">RedGreen</a> when working on rails projects and have gotten used to the visual feedback I get when tests pass or fail. It has definitely helped with my <a href="http://www.agileprogrammer.com/dotnetguy/archive/2006/08/01/17795.aspx">Red-Green-Refactor</a> flow.</p>
<p>I just found out phpunit supports colors in tests and it&#8217;s built-in as well. No gem installation required. Sweet!<br />
Turning on colours is done either with a <a href="http://www.phpunit.de/manual/current/en/textui.html">command line argument</a> or by adding an attribute to the <a href="http://www.phpunit.de/manual/current/en/appendixes.configuration.html">phpunit XML configuration file</a>.</p>
<p><strong>Command Line:</strong></p>
<pre>phpunit --colors testfile.php</pre>
<p><strong>XML File:</strong></p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;phpunit colors=&quot;true&quot;&gt;
	&lt;testsuite name=&quot;All Tests&quot;&gt;
		&lt;directory&gt;./&lt;/directory&gt;
	&lt;/testsuite&gt;
&lt;/phpunit&gt;
</pre>
<ul>
<li> <strong>No Colours:</strong><br />
<img class="console" src="/images/no-colour.gif" alt="No colour" /></li>
<li> <strong>Passing Tests &#8211; with colours:</strong><br />
<img class="console" src="/images/passing-tests.gif" alt="Passing Tests" /></li>
<li> <strong>Failing Tests &#8211; with colours:</strong><br />
<img class="console" src="/images/failing-tests.gif" alt="Failing Tests" /></li>
<li> <strong>Skipped or Incomplete Tests &#8211; with colours:</strong><br />
<img class="console" src="/images/skipped-tests.gif" alt="Skipped Tests" /></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/jazz-up-your-phpunit-test-results/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework &#8211; my three month review</title>
		<link>http://avnetlabs.com/php/zend-framework-my-three-month-review</link>
		<comments>http://avnetlabs.com/php/zend-framework-my-three-month-review#comments</comments>
		<pubDate>Thu, 06 Nov 2008 17:12:17 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/zend-framework-my-three-month-review</guid>
		<description><![CDATA[I have been using the Zend Framework almost daily for the past three months and my verdict on it is a mixed bag. I really, really wanted to like ZF three months ago when we chose to use it at work for our ongoing project and I do &#8211; with a few reservations.
I know my [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using the Zend Framework almost daily for the past three months and my verdict on it is a mixed bag. I really, really wanted to like ZF three months ago when we chose to use it at work for our ongoing project and I do &#8211; with a few reservations.</p>
<p>I know my verdict is tainted by Ruby on Rails and CodeIgniter (I&#8217;m proficient in the use of both of them) but it&#8217;s always nice to have a reference point. I&#8217;ll get my reservations out of the way first.</p>
<h3>What I don&#8217;t like</h3>
<ul>
<li><strong>Zend Framework Validation:</strong><br />
The Zend Framework has a very robust and flexible validation library. However the framework encourages validating data in the controller. In my view, validation is business logic and is thus a model function. Our current implementation actually moves the validation to the model (we added smarts to Zend_Db_Table_Row and implemented an ActiveRecord).</li>
<li><strong>Zend Forms:</strong><br />
In the same vein, ZF encourages creating complete forms in the controller. A form is HTML and belongs in the view. Furthermore we have designers working with us and as such real forms are preferable. On my own personal projects though, I suppose creating my form (including validation)  the Zend Way would actually speed up my work. The jury&#8217;s still out on that one, though.</li>
<li><strong>Learning curve:</strong><br />
ZF is complex. After three months I still haven&#8217;t covered all the fundamentals and constantly have the manual open. I guess this means it&#8217;s got a lot of functionality but it also means I&#8217;m still a ZF beginner.</li>
<li><strong>Verbosity:</strong><br />
 ZF has a more verbose syntax than the other frameworks I&#8217;m used to.</p>
<p>Compare the following view code:</p>
<pre class="brush: php; toolbar: false;">Zend Framework: &lt;?php echo $this-&gt;escape($this-&gt;name); ?&gt;;</pre>
<pre class="brush: ruby; toolbar: false;">Ruby on Rails: &lt;%= h(@name) %&gt;</pre>
<p>And the following controller code:</p>
<pre class="brush: php; toolbar: false;">
Zend Framework: $data = $this-&gt;getRequest()-&gt;getPost('name');
CodeIgniter: $data = $this-&gt;input-&gt;post('name');
</pre>
</li>
<li><strong>Flexibility:</strong><br />
The Zend Framework is flexible (perhaps too flexible?). For everything that needs doing in ZF, there are at least three ways of doing it. This means it&#8217;s highly unlikely that two applications written with ZF will be similar unlike a rigid framework like Rails or CakePHP. Comparing the source for <a href="http://www.magentocommerce.com/">Magento Commerce</a> and <a href="http://digitaluscms.com/">Digitalus CMS</a> (two open source web apps built on the Zend Framework) proves this.</li>
</ul>
<h3>What I do like</h3>
<ul>
<li>
<strong>Flexibility:</strong><br />
Yes, the flexibility is both a minus and a plus for me. ZF can be twisted to do practically anything you need it to do.<br />
The classes can be easily extended and have loads of configurable options. With ZF, if you can think it, you really can do it.
 </li>
<li>
<strong>The Education: </strong><br />
Browsing the Zend Framework source code is a real education in best practice PHP programming and the use of design patterns in PHP. ZF is clearly written by folks who know their stuff and really highlights the best of PHP5 programming.
</li>
<li>
<strong>Proper Decoupling: </strong><br />
The Zend Framework components honour the <a href="http://en.wikipedia.org/wiki/Open/closed_principle">open/closed principle</a> to the letter. The classes are so easy to extend and to reuse within and outside the framework. The ease with which modifications can be made actually encourage experimentation. A case in point is the ActiveRecord functionality we added to ZF. It&#8217;s a welcome change from all the intercoupling in CodeIgniter. I actually gave up trying to get CodeIgniter models to run isolated unit tests because the models needed an instance of the CI object to work.</p>
</li>
<li>
<strong>Zend Test: </strong><br />
ZF comes bundled with a built-in testing component based on <a href="http://www.phpunit.de/">PHPUnit</a> (since version 1.6). Actually that was the clincher for me in the choice of framework as the Zend&#8217;s IDE (more on this below) comes bundled with PHPUnit testing support. The test component does have a couple of things lacking (in my opinion database support would have been nice) but it wasn&#8217;t hard to extend it to our liking. Also, I&#8217;m sure with later versions, this component will be improved. CakePHP does have a better-featured test framework based on simpletest but I do like the IDE support (with code coverage) in the ZF offering.
</li>
<li>
<strong>Zend Studio: </strong><br />
<a href="http://www.zend.com/en/products/studio/features">Zend Studio</a> rocks! Zend Studio has built-in support for the Zend Framework, PHPUnit testing, code coverage, debugging and loads of other goodies to speed up PHP work. If you code PHP for a living, you owe it to yourself to check this out. The support for ZF has also eased the learning curve considerably. I still fall back to Dreamweaver if I&#8217;ve got extensive CSS or HTML code to write but I&#8217;m slowly starting to use Zend Studio even for these although DW is still way better.
</li>
</ul>
<p>
Would I use ZF for my own personal projects? It depends. I actually plan to use it for an application I will be realeasing next year but the motivation to use it is based on the modularity and the ease with which the framework can be extended and not development speed. For  a more focused web app, I&#8217;ll still stick with CI.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/zend-framework-my-three-month-review/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Tips for the budding PHP developer</title>
		<link>http://avnetlabs.com/php/tips-for-the-budding-php-developer</link>
		<comments>http://avnetlabs.com/php/tips-for-the-budding-php-developer#comments</comments>
		<pubDate>Tue, 30 Sep 2008 09:33:49 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/tips-for-the-budding-php-developer</guid>
		<description><![CDATA[The ease of learning PHP and the trivial deployment of PHP applications (just upload and go) has resulted in everyone&#8217;s cousin coding with it and the accompanying impression of being a &#8216;toy&#8217; language.
The following tips should help the aspiring PHP professional stand out from the crowd:

Step away from Dreamweaver
To write PHP code efficiently, you need [...]]]></description>
			<content:encoded><![CDATA[<p>The ease of learning PHP and the trivial deployment of PHP applications (just upload and go) has resulted in everyone&#8217;s cousin coding with it and the accompanying impression of being a &#8216;toy&#8217; language.</p>
<p>The following tips should help the aspiring PHP professional stand out from the crowd:</p>
<ul>
<li><strong>Step away from Dreamweaver</strong><br />
To write PHP code efficiently, you need an IDE designed for PHP. If most of your work is with HTML and CSS, you won&#8217;t find a better editor than Dreamweaver but if you primarily write PHP code, a PHP editor with features like real time error detection,  source control integration, code completion, refactoring support, debugging and built-in unit testing  helps big time.<br />
After using Zend Studio for a while now, I am a convert and the version 6.1 is really awesome.</li>
<li><strong>Get Certified</strong><br />
Writing the <a href="http://" title="http://www.zend.com/en/services/certification/php-5-certification/">PHP certification exam</a> forces you to read up on stuff you my not have come across in your day to day programming. The increased your employability is also a very welcome side effect.</li>
<li><strong>Use version control</strong><br />
You can thank me later &#8211; specifically when your client calls you up at 9 o&#8217;clock in the evening to tell you he&#8217;s overwritten some of the files you uploaded to his server.<br />
<a href="http://git.or.cz">Git</a> is the current version control golden boy but I&#8217;ve found <a href="http://subversion.tigris.org/">Subversion</a> to be stable and effective. Online version control services (e.g. <a href="http://www.springloops.com/">Springloops</a>, <a href="http://github.com/">Github</a>, <a href="http://cvsdude.com/">CVSDude</a> and <a href="http://beanstalkapp.com/">Beanstalk</a>) have also reduced the barrier to entry and there&#8217;s now to excuse not to do source control.</li>
<li><strong>Develop locally</strong><br />
Repeat after me &#8211; &#8216;I will not edit code on the production server&#8217;. It is essential to have a webserver running on your development machine. All code can be tested rigorously before being deployed to the production server (from the source control repository, obviously). <a href="http://www.wampserver.com/en/">WampServer</a> and <a href="http://www.apachefriends.org/en/xampp.html">Xampp</a> for Windows and <a href="http://www.mamp.info/en/index.php">Mamp</a> for the Mac take the stress off setting up a local web server. Use one of them.<br />
News Flash! &#8211; You don&#8217;t have to use Windows. Using a desktop Linux flavour (my choice is <a href="http://www.ubuntu.com/products/WhatIsUbuntu/desktopedition">Ubuntu</a>) gives you an environment as close as possible to your production server (assuming the PHP installation is on a Linux server &#8211; most are) and setting up webservers, virtual hosts and the like on these systems is also a lot easier (due partially to the massive amount of information on the internet).</li>
<li><strong>Don&#8217;t just write it, learn it</strong><br />
It&#8217;s amazing how much you can still learn even after working with PHP for years. Programming involves continuously updating your knowledge and skill-set and online resources and books should feature in your everyday work life. The PHP manual and Google are your friends.</li>
<li><strong>Learn a web framework</strong><br />
A web framework will speed up your code. Common plumbing tasks are already included and you just need to write code specific to your application. Choose one and learn it well.<br />
Which to choose? It depends. For the programmer just getting into OOP and frameworks, CodeIgniter is the easiest to learn but the rigidity of the <a href="http://cakephp.org/">CakePHP</a> framework may also appeal. My personal preference is a combination of <a href="http://codeigniter.com/">CodeIgniter</a> and the <a href="http://framework.zend.com/">Zend Framework</a>.</li>
<li><strong>Comment your code</strong><br />
The guy who gets to maintain your code after you will find you and hit you over the head with a big stick if you don&#8217;t comment your code. Coming back to your code after a while, chances are you won&#8217;t understand what some of the code you wrote is supposed to do.<br />
That said, most of the comments I write adhere to the <a href="http://www.phpdoc.org/">PHP Documentor</a> standard and I try not to add comments within method blocks but rely on the doc blocks to show intent (thus avoiding the issue of stale comments &#8211; changing implementation code and &#8216;forgetting&#8217; to change the comments). This also has the side effect of forcing me to keep my methods focused, which is good.</li>
<li><strong>Test Drive your code</strong><br />
You need to do unit testing. <a href="http://en.wikipedia.org/wiki/Test-driven_development">Test Driven Development</a> gives you a safety harness when making changes to already working code and a criteria for certifying a piece of code as working.<br />
<a href="http://www.phpunit.de/">PHPUnit</a> and <a href="http://www.simpletest.org/">SimpleTest</a> are most commonly used for PHP unit testing.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/tips-for-the-budding-php-developer/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Two step view with CodeIgniter</title>
		<link>http://avnetlabs.com/php/two-step-view-with-codeigniter</link>
		<comments>http://avnetlabs.com/php/two-step-view-with-codeigniter#comments</comments>
		<pubDate>Tue, 05 Aug 2008 14:48:27 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/two-step-view-with-codeigniter</guid>
		<description><![CDATA[All the web development frameworks I have worked with have a full fledged layout system out of the box except CodeIgniter. A good number of CI tutorials encourage  including common header and footer files to build the final page but I don&#8217;t like this approach for the following reasons:

It&#8217;s more difficult to swap layouts [...]]]></description>
			<content:encoded><![CDATA[<p>All the web development frameworks I have worked with have a full fledged layout system out of the box except CodeIgniter. A good number of CI tutorials encourage  including common header and footer files to build the final page but I don&#8217;t like this approach for the following reasons:</p>
<ul>
<li>It&#8217;s more difficult to swap layouts compared to using a single complete layout file.</li>
<li>You need to have a knowledge (admittedly small) of the  server-side language.</li>
<li>A single complete layout file can be viewed in a WYSIWYG editor.</li>
</ul>
<p>The layout system in the other frameworks I have worked with all use the two step view pattern and I have adapted CI to work the same way.</p>
<h3>What is a two step view?</h3>
<p>The idea behind using common header and footer files is to get a consistent look for your site or application and to make maintenance as painless as possible by providing a single place to make changes that affect the look and feel of the entire site or app.</p>
<p><a href="http://martinfowler.com/eaaCatalog/twoStepView.html">Quoting Martin Fowler</a>, the Two Step View pattern deals with this problem by splitting the transformation into two stages. The first transforms the model data into a logical presentation without any specific formatting; the second converts that logical presentation with the actual formatting needed. This way you can make a global change by altering the second stage, or you can support multiple output looks and feels with one second stage each.</p>
<h3>How it works</h3>
<p>
Rather than extend the CodeIgniter controller class directly, the controller classes extend a custom  base controller. This controller then extends the CI controller classes. The CI convention is to call this base controller class MY_Controller (default) and to place the class file in the libraries folder.
</p>
<p>
The base controller loads some default data and also has a render function which actually implements the two step view. I used the default Rails, Cake and Zend conventions of creating a folder named after the controller class and creating template files named after the actions. The render function does the first stage of the two step view pattern by checking if a file named after the action exists in folder named after a class. If it does, it loads it into a variable and then the second stage of the two step view pattern is implemented where this variable in addition to any other view data is injected into the layout file. So far, it&#8217;s worked great for me.
</p>
<h3>Some code, please</h3>
<ul>
<li class="tutorial-section"> <strong>The layout file</strong> (application/views/layouts/main.tpl.php)
<pre class="brush: php;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;

&lt;?php echo $css; ?&gt;

&lt;/head&gt;

&lt;body&gt;
    &lt;div id=&quot;page&quot;&gt;

        &lt;div id=&quot;header&quot;&gt;
            &lt;h1&gt;&lt;?php echo $title; ?&gt;&lt;/h1&gt;
            &lt;?php $this-&gt;load-&gt;view('partials/menu.tpl.php'); ?&gt;
        &lt;/div&gt;

        &lt;div id=&quot;content&quot;&gt;
            &lt;h2&gt;&lt;?php echo $heading; ?&gt;&lt;/h2&gt;
            &lt;?php echo $content; ?&gt;
        &lt;/div&gt;

        &lt;div id=&quot;footer&quot;&gt;
            &lt;p&gt;&amp;copy; 2008 AVNet Labs.&lt;/p&gt;
        &lt;/div&gt;

    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
</li>
<li class="tutorial-section"> <strong>The Base Controller</strong> (application/libraries/MY_Controller.php)
<pre class="brush: php;">
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class MY_Controller extends Controller {

	protected $data = array();
	protected $controller_name;
	protected $action_name;

	public function __construct() {
                parent::__construct();
		$this-&gt;load_defaults();
        }

	protected function load_defaults() {
		$this-&gt;data['heading'] = 'Page Heading';
		$this-&gt;data['content'] = '';
		$this-&gt;data['css'] = '';
		$this-&gt;data['title'] = 'Page Title';

		$this-&gt;controller_name = $this-&gt;router-&gt;fetch_directory() . $this-&gt;router-&gt;fetch_class();
		$this-&gt;action_name = $this-&gt;router-&gt;fetch_method();

	}

	protected function render($template='main') {
		$view_path = $this-&gt;controller_name . '/' . $this-&gt;action_name . '.tpl.php';
		if (file_exists(APPPATH . 'views/' . $view_path)) {
			$this-&gt;data['content'] .= $this-&gt;load-&gt;view($view_path, $this-&gt;data, true);
		}

		$this-&gt;load-&gt;view(&quot;layouts/$template.tpl.php&quot;, $this-&gt;data);
	}

	protected function add_css($filename) {
		$this-&gt;data['css'] .= $this-&gt;load-&gt;view(&quot;partials/css.tpl.php&quot;, array('filename' =&gt; $filename), true);
	}

}
?&gt;
</pre>
</li>
<li class="tutorial-section"> <strong>The Welcome Controller</strong> (application/controllers/welcome.php)
<pre class="brush: php;">
&lt;?php

class Welcome extends MY_Controller {

	function __construct() {
		parent::__construct();
		$this-&gt;add_css('main');
	}

	function index() {
		$this-&gt;data['heading'] = 'Home Page';
		$this-&gt;render();
	}

	function edit() {
		$this-&gt;data['heading'] = 'Edit Page';
		$this-&gt;render();
	}
}
</pre>
</li>
<li class="tutorial-section"> <strong>The Menu Partial Template</strong> (application/views/partials/menu.tpl.php)
<pre class="brush: php;">
&lt;ul&gt;
 &lt;li&gt;&lt;a href=&quot;&lt;?php echo site_url(); ?&gt;&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;&lt;?php echo site_url('welcome/edit'); ?&gt;&quot;&gt;Edit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
</li>
<li class="tutorial-section"> <strong>The CSS Partial Template</strong> (application/views/partials/css.tpl.php)
<pre class="brush: php;">
&lt;link href=&quot;&lt;?php echo base_url() . 'css/' . $filename . '.css'; ?&gt;&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
</pre>
</li>
<li class="tutorial-section"> <strong>The Homepage Template</strong> (application/views/welcome/index.tpl.php)
<pre class="brush: php;">
&lt;p&gt;Home page stuff goes here&lt;/p&gt;
</pre>
</li>
<li class="tutorial-section"> <strong>The Edit Page Template</strong> (application/views/welcome/edit.tpl.php)
<pre class="brush: php;">
&lt;p&gt;Edit page stuff goes here&lt;/p&gt;
</pre>
</li>
</ul>
<h3>Update</h3>
<p>
ReLexEd added a comment pointing out that my original base controller code wouldn&#8217;t work with controllers in a subdirectory.<br />
I have updated the base class to use the router object.<br />
I was initially using segments to work out the view paths and although it&#8217;s been working for me, using the router is more robust.
</p>
<p>
For the controllers in subdirectories, the views also need to be in subdirectories eg. an index method in a  controller at &#8216;application/controllers/admin/dashboard.php&#8217; will have a corresponding view file at &#8216;application/views/admin/dashboard/index.tpl.php&#8217;
</p>
<p>
NB. To use the base_url() method in the css partial template, the url helper must be autoloaded.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/two-step-view-with-codeigniter/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>PHP framework comparison benchmarks</title>
		<link>http://avnetlabs.com/php/php-framework-comparison-benchmarks</link>
		<comments>http://avnetlabs.com/php/php-framework-comparison-benchmarks#comments</comments>
		<pubDate>Mon, 30 Jun 2008 06:00:42 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/php-framework-comparison-benchmarks</guid>
		<description><![CDATA[In response to Wil&#8217;s comment regarding the PHP framework performance comparisons I made in my previous post, I have  decided to post the results I got.
My decision not post them initially was due to the benchmarks not being done in complete isolation (a seperate client and server machine) but the scores relative to each [...]]]></description>
			<content:encoded><![CDATA[<p>In response to Wil&#8217;s comment regarding the PHP framework performance comparisons I made in <a href="http://www.avnetlabs.com/php/php-frameworks-revisited-codeigniter-vs-zend-framework" title="PHP framework revisited">my previous post</a>, I have  decided to post the results I got.<br />
My decision not post them initially was due to the benchmarks not being done in complete isolation (a seperate client and server machine) but the scores relative to each should still be accurate and that&#8217;s what I am testing for.</p>
<p>Furthermore, while I only used requests/sec as a performance yardstick, I do realize that other factors do affect a web application&#8217;s response in the real world.</p>
<h3>The Tools</h3>
<p>The tests were run on a 1.8Ghz AMD sempron computer with 512Mb RAM running Ubuntu Gutsy (7.10) Desktop.<br />
I used <a href="http://www.hpl.hp.com/research/linux/httperf/">httperf</a> to run the tests although I did run some of them again using apachebench and the results were consistent.</p>
<p>I created the same front page with CakePHP, CodeIgniter, Zend Framework and Ruby on Rails. I also duplicated the same functionality in HTML and in PHP using procedural code (aka. spaghetti code) to act as baselines.</p>
<p>I decided to include data access in the tests and the tests involve the application fetching four rows from the database and rendering the results.</p>
<p><a href="http://avnetlabs.com/frameworks/">View the sample page.</a></p>
<p>The test files are also  available for download for those interested in them. The sql file for the mysql database is also included. The code assumes a database root user with no password.</p>
<ul>
<li><a href="http://avnetlabs.com/frameworks/frameworks.tar.gz">Get the tar file</a></li>
<li><a href="http://avnetlabs.com/frameworks/frameworks.zip">Get the zip file</a></li>
</ul>
<h3>The Results</h3>
<p>All scores are requests per second. Higher is better.</p>
<ul>
<li> <strong>No PHP code cache</strong><br />
All frameworks used an ORM (of sorts, in the case of codeigniter). The Zend Framework used Zend_DB_Table and CodeIgniter used ActiveRecord.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">Baseline HTML</td>
<td>
<p align="right">1327.5</p>
</td>
<td>
<p align="right">1326.5</p>
</td>
<td>
<p align="right">1328.6</p>
</td>
<td>
<p align="right">1329.1</p>
</td>
<td>
<p align="right"><strong>1327.9</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Baseline PHP</td>
<td>
<p align="right">331.6</p>
</td>
<td>
<p align="right">332.1</p>
</td>
<td>
<p align="right">331.4</p>
</td>
<td>
<p align="right">332.0</p>
</td>
<td>
<p align="right"><strong>331.8</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CakePHP</td>
<td>
<p align="right">3.6</p>
</td>
<td>
<p align="right">3.7</p>
</td>
<td>
<p align="right">3.8</p>
</td>
<td>
<p align="right">3.5</p>
</td>
<td>
<p align="right"><strong>3.7</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">21.5</p>
</td>
<td>
<p align="right">21.2</p>
</td>
<td>
<p align="right">21.7</p>
</td>
<td>
<p align="right">21.7</p>
</td>
<td>
<p align="right"><strong>21.5</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">9.3</p>
</td>
<td>
<p align="right">9.1</p>
</td>
<td>
<p align="right">9.2</p>
</td>
<td>
<p align="right">9.3</p>
</td>
<td>
<p align="right"><strong>9.2</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>With eAccelerator PHP code cache</strong><br />
All frameworks used an ORM (of sorts, in the case of CodeIgniter). The Zend Framework used Zend_DB_Table and CodeIgniter used ActiveRecord.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">CakePHP</td>
<td>
<p align="right">8.0</p>
</td>
<td>
<p align="right">8.0</p>
</td>
<td>
<p align="right">8.0</p>
</td>
<td>
<p align="right">7.2</p>
</td>
<td>
<p align="right"><strong>7.8</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">98.2</p>
</td>
<td>
<p align="right">98.1</p>
</td>
<td>
<p align="right">98.3</p>
</td>
<td>
<p align="right">98.3</p>
</td>
<td>
<p align="right"><strong>98.2</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">33.2</p>
</td>
<td>
<p align="right">33.3</p>
</td>
<td>
<p align="right">33.5</p>
</td>
<td>
<p align="right">33.6</p>
</td>
<td>
<p align="right"><strong>33.4</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>With APC PHP code cache</strong><br />
All frameworks used an ORM (of sorts, in the case of CodeIgniter). The Zend Framework used Zend_DB_Table and CodeIgniter used ActiveRecord.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">CakePHP</td>
<td>
<p align="right">7.3</p>
</td>
<td>
<p align="right">7.3</p>
</td>
<td>
<p align="right">7.3</p>
</td>
<td>
<p align="right">7.3</p>
</td>
<td>
<p align="right"><strong>7.3</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">97.5</p>
</td>
<td>
<p align="right">98.0</p>
</td>
<td>
<p align="right">96.6</p>
</td>
<td>
<p align="right">98.3</p>
</td>
<td>
<p align="right"><strong>97.6</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">32.8</p>
</td>
<td>
<p align="right">33.3</p>
</td>
<td>
<p align="right">31.8</p>
</td>
<td>
<p align="right">32.7</p>
</td>
<td>
<p align="right"><strong>32.7</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>With APC PHP code cache, No ORM</strong><br />
The Zend Framework used Zend_DB and I disabled ActiveRecord in CodeIgniter. I couldn&#8217;t figure out how to disable the ORM in cakePHP so I left it out.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">106.4</p>
</td>
<td>
<p align="right">105.6</p>
</td>
<td>
<p align="right">106.3</p>
</td>
<td>
<p align="right">106.6</p>
</td>
<td>
<p align="right"><strong>106.2</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">42.6</p>
</td>
<td>
<p align="right">42.8</p>
</td>
<td>
<p align="right">42.9</p>
</td>
<td>
<p align="right">43.0</p>
</td>
<td>
<p align="right"><strong>42.8</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>With APC PHP code cache, No database calls</strong><br />
This tests the impact of the database call on the overall performance. I sent an empty result set to the view directly from the controller, thus bypassing the model.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">118.1</p>
</td>
<td>
<p align="right">118.3</p>
</td>
<td>
<p align="right">117.3</p>
</td>
<td>
<p align="right">118.2</p>
</td>
<td>
<p align="right"><strong>118.0</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">51.9</p>
</td>
<td>
<p align="right">52.1</p>
</td>
<td>
<p align="right">52.1</p>
</td>
<td>
<p align="right">52.2</p>
</td>
<td>
<p align="right"><strong>52.0</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>Ruby on Rails comparison</strong><br />
I added this test to see how the PHP frameworks stcked up against Ruby on Rails. I also used the chance to try out Passenger (mod_rails) and Ruby Enterprise.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">ROR with 1 Mongrel</td>
<td>
<p align="right">88.1</p>
</td>
<td>
<p align="right">85.1</p>
</td>
<td>
<p align="right">84.9</p>
</td>
<td>
<p align="right">84.8</p>
</td>
<td>
<p align="right"><strong>85.7</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">ROR with Passenger</td>
<td>
<p align="right">85.2</p>
</td>
<td>
<p align="right">97.3</p>
</td>
<td>
<p align="right">86.3</p>
</td>
<td>
<p align="right">84.2</p>
</td>
<td>
<p align="right"><strong>88.2</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">ROR with Passenger and Ruby Enterprise</td>
<td>
<p align="right">89.0</p>
</td>
<td>
<p align="right">99.2</p>
</td>
<td>
<p align="right">98.9</p>
</td>
<td>
<p align="right">98.6</p>
</td>
<td>
<p align="right"><strong>96.4</strong></p>
</td>
</tr>
</table>
</li>
</ul>
<h3>Conclusion</h3>
<p>CodeIgniter is over twice the speed of the Zend framework in all cases and CakePHP is a lot slower than the other two PHP frameworks. I do admit that considering my experience with CodeIgniter, I might have inadvertently set it up optimally without doing the same to the other two frameworks. I have posted the files and I welcome comments from &#8220;the experts&#8221;.</p>
<h3>Update</h3>
<p>We have decided to use the Zend framework so obviously outright performance is not the only factor in the choice of framework. The results we are currently getting are fast enough for us and in our existing application, the database is the bottleneck not the PHP code.</p>
<p>I have also done a few more tests on a production-grade dual-core server with 2Gb of RAM running Centos 5. This time, all benchmarks were from a seperate client computer on the same network. I used the exact same files as the previous results except for CakePHP where I used the recently released RC2. The results follow.</p>
<ul>
<li> <strong>No PHP code cache</strong>
<p>All frameworks used an ORM (of sorts, in the case of codeigniter). The Zend Framework used Zend_DB_Table and CodeIgniter used ActiveRecord.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">Baseline HTML</td>
<td>
<p align="right">3431.2</p>
</td>
<td>
<p align="right">3311.8</p>
</td>
<td>
<p align="right">3427.7</p>
</td>
<td>
<p align="right">3395.0</p>
</td>
<td>
<p align="right"><strong>3391.4</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Baseline PHP</td>
<td>
<p align="right">1912.1</p>
</td>
<td>
<p align="right">1932.3</p>
</td>
<td>
<p align="right">1983.3</p>
</td>
<td>
<p align="right">1911.3</p>
</td>
<td>
<p align="right"><strong>1934.7</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CakePHP</td>
<td>
<p align="right">15.6</p>
</td>
<td>
<p align="right">15.6</p>
</td>
<td>
<p align="right">15.6</p>
</td>
<td>
<p align="right">15.6</p>
</td>
<td>
<p align="right"><strong>15.6</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">83.5</p>
</td>
<td>
<p align="right">83.0</p>
</td>
<td>
<p align="right">82.0</p>
</td>
<td>
<p align="right">83.2</p>
</td>
<td>
<p align="right"><strong>82.9</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">34.7</p>
</td>
<td>
<p align="right">34.6</p>
</td>
<td>
<p align="right">34.6</p>
</td>
<td>
<p align="right">34.6</p>
</td>
<td>
<p align="right"><strong>34.6</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>With eAccelerator PHP code cache</strong>
<p>All frameworks used an ORM (of sorts, in the case of CodeIgniter). The Zend Framework used Zend_DB_Table and CodeIgniter used ActiveRecord.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">CakePHP</td>
<td>
<p align="right">36.0</p>
</td>
<td>
<p align="right">36.1</p>
</td>
<td>
<p align="right">36.1</p>
</td>
<td>
<p align="right">36.2</p>
</td>
<td>
<p align="right"><strong>36.1</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">383.3</p>
</td>
<td>
<p align="right">377.9</p>
</td>
<td>
<p align="right">371.8</p>
</td>
<td>
<p align="right">385.2</p>
</td>
<td>
<p align="right"><strong>379.5</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">129.2</p>
</td>
<td>
<p align="right">128.5</p>
</td>
<td>
<p align="right">129.0</p>
</td>
<td>
<p align="right">128.9</p>
</td>
<td>
<p align="right"><strong>128.9</strong></p>
</td>
</tr>
</table>
</li>
<li> <strong>With the Zend Platform</strong>
<p>All frameworks used an ORM (of sorts, in the case of CodeIgniter). The Zend Framework used Zend_DB_Table and CodeIgniter used ActiveRecord.</p>
<table class="frameworks" width="100%">
<tr>
<td></td>
<td class="highlight-cell">
<p align="right">Run 1</p>
</td>
<td class="highlight-cell">
<p align="right">Run 2</p>
</td>
<td class="highlight-cell">
<p align="right">Run 3</p>
</td>
<td class="highlight-cell">
<p align="right">Run 4</p>
</td>
<td class="highlight-cell">
<p align="right">Average</p>
</td>
</tr>
<tr>
<td class="highlight-cell">CakePHP</td>
<td>
<p align="right">24.7</p>
</td>
<td>
<p align="right">24.8</p>
</td>
<td>
<p align="right">24.9</p>
</td>
<td>
<p align="right">24.8</p>
</td>
<td>
<p align="right"><strong>24.8</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">CodeIgniter</td>
<td>
<p align="right">255.0</p>
</td>
<td>
<p align="right">256.6</p>
</td>
<td>
<p align="right">254.1</p>
</td>
<td>
<p align="right">253.8</p>
</td>
<td>
<p align="right"><strong>254.9</strong></p>
</td>
</tr>
<tr>
<td class="highlight-cell">Zend Framework</td>
<td>
<p align="right">83.5</p>
</td>
<td>
<p align="right">84.4</p>
</td>
<td>
<p align="right">83.8</p>
</td>
<td>
<p align="right">83.4</p>
</td>
<td>
<p align="right"><strong>83.8</strong></p>
</td>
</tr>
</table>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/php-framework-comparison-benchmarks/feed</wfw:commentRss>
		<slash:comments>103</slash:comments>
		</item>
		<item>
		<title>PHP frameworks revisited &#8211; CodeIgniter vs Zend</title>
		<link>http://avnetlabs.com/php/php-frameworks-revisited-codeigniter-vs-zend-framework</link>
		<comments>http://avnetlabs.com/php/php-frameworks-revisited-codeigniter-vs-zend-framework#comments</comments>
		<pubDate>Tue, 24 Jun 2008 19:30:00 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/php-frameworks-revisited-codeigniter-vs-zend-framework</guid>
		<description><![CDATA[We are about to start a project from scratch at my new job and have been evaluating PHP frameworks. We&#8217;ve shortlisted CakePHP, CodeIgniter, Symfony and Zend.
I have put them through their paces by building the same application with all four of them (a simple wiki application) and hopefully, we&#8217;ll settle on one soon enough.
Full Disclosure: [...]]]></description>
			<content:encoded><![CDATA[<p>We are about to start a project from scratch at my new job and have been evaluating PHP frameworks. We&#8217;ve shortlisted CakePHP, CodeIgniter, Symfony and Zend.<br />
I have put them through their paces by building the same application with all four of them (a simple wiki application) and hopefully, we&#8217;ll settle on one soon enough.</p>
<p>Full Disclosure: I have tried to be as unbiased as I possibly can but I&#8217;m already a CodeIgniter fan. That said, the company I work for is a Zend Partner (we already use the Zend Platform and Zend Studio) and I can&#8217;t help factoring that in.</p>
<p>Although the initial plan was to review four PHP frameworks, this post has become a direct CodeIgniter to Zend Framework comparison. I have had to exclude Symfony and CakePHP from the list after spending a few hours going through all four frameworks for the following reasons:</p>
<ul>
<li><strong>Learning curve:<br />
</strong>Both symphony and CakePHP have a very steep learning curve. CakePHP has strict rules about database table names, where files should be placed, method names and class names. Symfony stores its configuration in .yml format (requires learning although it’s not really that hard) and a lot of the interaction with the application is through a console. Creating database tables, data models and various other files are done using the command line.</li>
<li><strong>Strict ORM:</strong><br />
CakePHP and Symphony have full-blown object-relational mappers (ORM) to provide access to the database and these cannot be disabled without a lot of effort. These ORM have strict rules and conventions which must be adhered to for the application to work.<br />
In contrast the Zend Framework and CodeIgniter are flexible about using models and how they are used. Using a model is optional and while they each have data mappers, applications can work without them. The application will be extremely database intensive and we would rather not be limited in our choices.</li>
<li><strong>Flexibility:<br />
</strong>The Zend Framework and CodeIgniter are more flexible than the other two frameworks.</li>
</ul>
<h3>The Duel</h3>
<table id="frameworks" width="100%">
<tr>
<td class="highlight-cell" valign="top" width="19%">&nbsp;</td>
<td class="highlight-cell" valign="top" width="40%"><strong>CodeIgniter</strong></td>
<td class="highlight-cell" valign="top" width="40%"><strong>Zend Framework</strong></td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Set Up</strong></td>
<td valign="top">CodeIgniter is very easy to set up. Copy all the framework files to the web server and it’s good to go. It also has a small folder size – about 2.1 Mb and I could display the default home page less than five minutes after I started the set-up.</td>
<td valign="top">The Zend Framework requires a bit of effort to setup the project. It requires the creation of a bootstrap file with all the initialisation stuff it. The framework is relatively large – about 12.4Mb and the set-up process took about 19 minutes.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Documentation</strong></td>
<td valign="top">The documentation is very well-structured and organized although it is a bit less detailed than the Zend framework documentation.<br />
CodeIgniter also has forums and a wiki which feature a lot of user-submitted code.</td>
<td valign="top">The Zend Framework has very detailed documentation with a lot of examples. It is less organised than the CodeIgniter docs in my view although this could be down to the afore-mentioned detail and the large number of components available in the framework.ZF also has a wiki with a few tutorials.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Templating</strong></td>
<td valign="top">CodeIgniter includes a template parser class although in my opinion its use is limited as it does not support logic (e.g. if statements) in the views.However the CI recommendation is to use PHP tags in the views.</td>
<td valign="top">The Zend framework includes a Layout class designed to provide a common layout (or multiple layouts) for the entire website or application. It uses PHP tags for templating although it does provide an abstract view class which can be extended with a 3<sup>rd</sup> party template library.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Components</strong></td>
<td valign="top">CI has a lot of libraries and helpers to simplify the developer’s life.While it does have less of these than ZF, in the main, the usage of the CI variants is simpler.</td>
<td valign="top">ZF has a massive number of classes and components.These are well documented although the usage is usually a bit more difficult than in CI.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Database Access</strong></td>
<td valign="top">CI includes a database class which handles the database connection. The database class can be used for standard SQL queries creating, retrieving, updating and deleting data in the standard PHP way.CI also includes an active record class which is a modified version of the Active Record Database Pattern. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases only one or two lines of code are necessary to perform a database action.Beyond simplicity, a major benefit to using the Active Record features is that it allows the creation of database independent applications, since the query syntax is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.</td>
<td valign="top">Zend_Db and its related classes provide a simple SQL database interface for Zend Framework. It allows for standard SQL queries but simplifies retrieving the SQL results.It also includes an ORM using both the Table Data Gateway and the Row Data Gateway. These represent the database table and row respectively as objects and can drastically reduce development speed.The downside is a slight performance deficit when compared to the modified active record pattern used in CodeIgniter which does not use objects as extensively.Zend_Db can also model table relationships in PHP classes making database joins a breeze.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Flexibility</strong></td>
<td valign="top">CI is very flexible allowing almost all defaults to be modified.</td>
<td valign="top">ZF is simply a collection classes and as such any file or folder can be placed anywhere as long as the location is added to the bootstrap file.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Validation</strong></td>
<td valign="top">Data validation in CodeIgniter is handled via a validation class. A set of rules gets defined and assigned to the validation object.The validation object automatically validates the data passed via the URL or form. From there, the programmer can decide how that gets handled.The validation class can also help automate some of the process of setting error messages for specific fields.</td>
<td valign="top">The Zend_Validate component provides a set of commonly needed validators. It also provides a simple validator chaining mechanism by which multiple validators may be applied to a single datum in a user-defined order.In ZF, each validator is a separate class and the class is added to the data (like a filter) rather than the data being passed into the class like it is in CodeIgniter.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Forms</strong></td>
<td valign="top">The Form Helper file in CI contains functions that assist in working with forms.It aids in the generation of form fields although it does not completely eliminate the need to write HTML code.</td>
<td valign="top">Zend_Form simplifies form creation and handling. It handles element filtering and validation, escaping data and form rendering.Using Zend_Form, ZF can represent a form completely in PHP code including labels, validation and error messages.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Performance</strong></td>
<td valign="top">CI has about double the performance of the Zend Framework.</td>
<td valign="top">The Zend Framework is about half as fast as CodeIgniter.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Testing</strong></td>
<td valign="top">CodeIgniter has a unit testing class but it encourages mixing the test code with the actual source code so I don’t recommend it.A third-party extension for SimpleTest is available though.Using PHPUnit with the CI classes should also be possible.</td>
<td valign="top">The Zend Framework does not have a built-in unit testing class but the core classes use PHPUnit as their test framework and this can be extended to include any additional classes.Using SimpleTest with the ZF classes should also be possible.</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>Internationalisation</strong></td>
<td valign="top">No</td>
<td valign="top">Yes</td>
</tr>
<tr>
<td class="highlight-cell" valign="top"><strong>License</strong></td>
<td valign="top">BSD-style</td>
<td valign="top">New BSD</td>
</tr>
</table>
<h3>Summary</h3>
<p>I was rather surprised at the performance difference (measured using apachebench loading the home page with one call to the database to retrieve four rows). I expected the efficiency of using PHP5 only features to make up for the extra size of the Zend framework.</p>
<p>The Zend Framework advantages include:</p>
<ul>
<li>The “official PHP framework”.</li>
<li>My workplace is already a Zend “partner”.</li>
<li>Full-featured layout and template system.</li>
<li>Massive number of classes and components.</li>
<li>Extremely flexible.</li>
<li>More advanced database library.</li>
<li>More advanced validation library.</li>
<li>Internationalization support.</li>
</ul>
<p>CodeIgniter advantages include:</p>
<ul>
<li>Extremely easy to setup.</li>
<li>Lower learning curve then the Zend Framework.</li>
<li>More accessible documentation.</li>
<li>Concise syntax – The Zend Framework syntax is wordier.</li>
<li>100% faster than the Zend framework.</li>
</ul>
<p>There isn’t any clear cut “winner” here in my opinion and we still haven&#8217;t chosen one yet.</p>
<p>Update: the <a href="http://www.avnetlabs.com/php/php-framework-comparison-benchmarks" title="PHP framework comparison benchmarks">benchmarks</a> are now available</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/php-frameworks-revisited-codeigniter-vs-zend-framework/feed</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Apache mod_rewrite on Windows</title>
		<link>http://avnetlabs.com/php/apache-mod_rewrite-on-windows</link>
		<comments>http://avnetlabs.com/php/apache-mod_rewrite-on-windows#comments</comments>
		<pubDate>Fri, 13 Jun 2008 11:18:07 +0000</pubDate>
		<dc:creator>Ekerete</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.avnetlabs.com/php/apache-mod_rewrite-on-windows</guid>
		<description><![CDATA[I use Windows XP as my development platform and this is more of a note from me to me so I don&#8217;t have to Google for it next time.
I also use WampServer for Apache, MySQL and PHP and while I&#8217;ve only tested on that stack, I believe it to be generic enough.

Open the Apache httpd.conf [...]]]></description>
			<content:encoded><![CDATA[<p>I use Windows XP as my development platform and this is more of a note from me to me so I don&#8217;t have to Google for it next time.</p>
<p>I also use <a href="http://www.en.wampserver.com/">WampServer</a> for Apache, MySQL and PHP and while I&#8217;ve only tested on that stack, I believe it to be generic enough.</p>
<ul>
<li>Open the Apache httpd.conf file and uncomment the line &#8216;LoadModule rewrite_module modules/mod_rewrite.so&#8217; (remove the pound &#8216;#&#8217; sign from in front of the line).</li>
<li>If the lines &#8216;ClearModuleList&#8217; and &#8216;AddModule mod_rewrite.c&#8217; are in your httpd.conf file, make sure they are not commented out.</li>
<li>Find the section with Document Root: DocumentRoot &#8220;C:/path/to/my/root&#8221;</li>
<li>Modify the option for AllowOverride to look like this:      <br />&lt;Directory /&gt;      <br />&#160;&#160;&#160; Options Indexes FollowSymLinks      <br />&#160;&#160;&#160; AllowOverride All      <br />&lt;/Directory&gt;</li>
<li>Restart Apache</li>
</ul>
<p>Apache mod-rewrite should now be working.</p>
]]></content:encoded>
			<wfw:commentRss>http://avnetlabs.com/php/apache-mod_rewrite-on-windows/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.530 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-29 01:40:42 -->
