10 Compelling Reasons to Use Zend Framework

10 Compelling Reasons to Use Zend Framework

Tutorial Details
  • Technologies: PHP, Zend Framework
  • Difficulty: Intermediate
  • Estimated Completion Time: 1 hour

Trying to decide which framework to use for your new project? In this article, we’ll go in-depth about why Zend Framework should absolutely be your PHP framework of choice.


Introduction

Whether you’re starting a new project or improving an existing one, in this article, I’ve provided ten reasons why you should use Zend Framework for your next project, and hopefully, it helps you in making an informed decision.


Reason 1. Extend Classes like There’s no Tomorrow

Zend Framework is a fully object-oriented framework, and as such, it utilizes a lot of object-oriented (OO) concepts like inheritance and interfaces. This makes most, if not all, of ZF’s components extendable to some point. It allows developers to implement their own special variations of individual components without having to hack into the ZF codebase itself. Being able to customize ZF this way allows you to create functionality that is unique to your project, but because of its object-oriented nature, you’ll be able to use this functionality in other projects as well.

Example

Zend Framework has a very extensive Validation component, which you can use to validate data coming from forms. In ZF, forms are treated as objects as well, and are represented by the Zend_Form component.

Let’s assume that you want to create a custom URL validator to restrict URL input from the user. The quickest way to do this would be to just validate the input using something like:

$isValid = filter_var($submitted_url, FILTER_VALIDATE_URL);

But this won’t adhere to the OO nature of form objects, since it’s not used within the context of the form. To solve this, we can create a new Zend_Validator class by extending the Zend_Validate_Abstract class:

<?php
class Zend_Validate_Url extends Zend_Validate_Abstract
{
	const INVALID_URL = 'invalidUrl';
	
	protected $_messageTemplates = array(
		self::INVALID_URL   => "'%value%' is not a valid URL.",
	);
	
	public function isValid($value)
	{
		$valueString = (string) $value;
		$this->_setValue($valueString);
		
		if (!Zend_Uri::check($value)) {
			$this->_error(self::INVALID_URL);
			return false;
		}
		return true;
	}
}

This actually uses the Zend_Uri class, which already has a URL checking method we can use. But since it doesn’t extend the Zend_Validate_Abstract class, we implemented a wrapping class which does implement the needed abstract class. This lets us use the Zend_Uri URL checking function in our Zend_Form objects like so:

<?php 
class Form_Site extends Zend_Form 
{
	public function init()
	{
		$this->setMethod('POST');
		$this->setAction('/index');
		
		$site= $this->createElement('text', 'siteurl'); 
		$site->setLabel('Site URL'); 
		$site->setRequired(true);
		
		//  Adding the custom validator here!
		$site->addValidator(new Zend_Validate_Url());
		$this->addElement($site);
		$this->addElement('submit', 'sitesubmit', array('label' => 'Submit'));
	}

}

If we wanted to check that our URLs are valid YouTube video URLs, we could do something like this:

<?php
class Zend_Validate_YouTubeUrl extends Zend_Validate_Abstract
{
	const INVALID_URL = 'invalidUrl';
	
	protected $_messageTemplates = array(
		self::INVALID_URL   => "'%value%' is not a valid URL.",
	);
	
	public function isValid($value)
	{
		$valueString = (string) $value;
		$this->_setValue($valueString);
		
		if (strpos($value, "http://www.youtube.com/watch?v=") !== 0) {
			$this->_error(self::INVALID_URL);
			return false;
		}
		return true;
	}
}

If we added this to our site form object as a validator, it would ensure that all URLs submitted begin with the correct YouTube video URL prefix.


Reason 2. Object-oriented Goodness


Image courtesy of http://www.developer.com

In Zend Framework, everything is an object, as proven by our example above. This poses its own disadvantages, such as making things more complicated to code. Its main advantage, though, is the ability to make code reusable, and since nobody likes to repeat themselves, this is a very good thing.

Example

We already have our Zend_Validate_Url and Form_Site class from our example above, so let’s reuse them in this example.

<?php

class IndexController extends Zend_Controller_Action
{

    public function indexAction()
    {
		$siteform = new Form_Site();

		if( $this->_request->isPost() && $siteform->isValid($this->_request->getPost()) ) {
			//stuff to do if the input is correct
			$this->_redirect("/index/correct");
		}
		$this->view->siteform = $siteform;
    }

    public function correctAction()
    {
		// Yay, we're re-using our Form_Site object!
		$this->view->siteform = new Form_Site();
    }
}

Here’s what it would look like on a browser:

If you tried to submit an invalid URL, you can see our URL validator at work:

Here, you can see what would happen if you did input a valid URL:

As you can see, we’ve never had to repeat our form object code.

“Zend_Validate classes can be used in other ways as well, not only within the context of Zend_Form classes. You simply instantiate a Zend_Validate class and call the isValid($parameter) method, passing it the value you want to validate.”


Reason 3. Use What you Need, Forget Everything Else

Image courtesy of http://dev.juokaz.com

By design, Zend Framework is simply a collection of classes. Normally, you’ll use Zend MVC components to create a fully-functional ZF project, but in any other case, you can just load the components you need. ZF is very decoupled, which means we can take advantage of the components as individual libraries, instead of the framework as a whole.

If you’ve been looking at other framework articles, you’ve probably heard of the term glue framework. ZF, by default, is a glue framework. Its decoupled nature makes it easy to use as “glue” to your already existing application.

There’s a debate between using glue frameworks vs. full-stack frameworks. Full-stack frameworks are those that provide you everything you need to create your project, like ORM implementations, code-generation, or scaffolding. Full-stack frameworks require the least amount of effort to create a project, but fall short in terms of flexibility, since it imposes strict conventions on your project.

Example

Let’s say you need a way to retrieve information about a specific video on YouTube. Zend_Gdata_Youtube is a ZF component which allows you to access data from YouTube via the GData API. Retrieving the video information is as simple as:

//Make sure you load the Zend_Gdata_Youtube class, this assume ZF is in your PHP's include_path
include_once "Zend/Gdata/Youtube.php";

$yt = new Zend_Gdata_YouTube();
// getVideoEntry takes in the YouTube video ID, which is usually the letters at the end
// of a YouTube URL e.g. http://www.youtube.com/watch?v=usJhvgWqJY4
$videoEntry = $yt->getVideoEntry('usJhvgWqJY4');
echo 'Video: ' . $videoEntry->getVideoTitle() . "<br />";
echo 'Video ID: ' . $videoEntry->getVideoId() . "<br />";
echo 'Updated: ' . $videoEntry->getUpdated() . "<br />";
echo 'Description: ' . $videoEntry->getVideoDescription() . "<br />";
echo 'Category: ' . $videoEntry->getVideoCategory() . "<br />";
echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "<br />";
echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "<br />";
echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "<br />";
echo 'Duration: ' . $videoEntry->getVideoDuration() . "<br />";
echo 'View count: ' . $videoEntry->getVideoViewCount() . "<br />";

Code sample courtesy of Google Developer’s Guide

This code would output:

One thing to note here: this Zend Framework component (GData) is the official PHP library endorsed by Google to access its API. The framework’s decoupled nature allows us to use the component in any project, regardless of the framework we used to build it.


Reason 4. It lets you do a Lot of Things!

One of the things I love most about Zend Framework is that it has A LOT of components. Need a way to authenticate a user? Use Zend_Auth. Need to control access to your resources? Look up Zend_Acl. Need to create some forms? We have Zend_Form. Need to read an RSS feed? You can use Zend_Feed for that. It’s basically the Swiss Army knife of PHP classes!

Zend actually comes with some demos that show how to use its different components:

To view these, the best way is to simply download the Full Package Version of Zend Framework and test them out on your machine.

For a complete list of all the components, you can check out the Zend Framework Manual.


Reason 5. No Model Implementation – Choose your Own Adventure!

Image courtesy of http://www.vintagecomputing.com

This is actually one of the reasons most developers don’t use Zend Framework – it has no Model implementation on its own. For those who don’t know what a Model is, it’s the M in MVC, which stands for “Model-View-Controller”, a programming architecture that’s used by most PHP Frameworks.

Does that mean that Zend Framework is only a “VC” Framework?

Yes, and no.

Yes, it’s a VC framework because it doesn’t have its own Model implementation. This makes it hard for some people to use ZF, especially if they’re coming from a framework which does have a Model implementation (like CakePHP, Symfony, or even Ruby on Rails).

On the other hand, no, it’s an MVC framework as well, since apart from providing the generic ways to access the database (using Zend_Db), it actually still relies on some sort of Model implementation. What it does differently is that it leaves this kind of implementation up to the developer ñ which some say should be the case since models are actually where the business logic of the application resides, and therefore, they’re not something which can be developed as a generic component. Zend Framework Philosophy states that model implementations are unique to the projectóit’s impossible to create an abstract implementation of it since they don’t really know what you need. They believe that models should be implemented by the developers themselves.

How is this a good thing?

Not having a Model implementation means that the developer is free to use whatever means he has to implement it, or even just integrate existing implementations. Being free of predefined restraints, the developer is then allowed to create more complex implementations, rather than just simple representations of tables, which is how usual Model implementations are created. Models contain your business logic. They should not be restrained by your database tables; rather, they should dictate the connections of these tables to one another. This lets you put most of your programming code in your Models, therefore satisfying the “Thin Controllers, Fat Models” paradigm of MVC.

So how will I use Zend Framework if I have no idea how to create my own models?

For beginners, the Zend Framework Quickstart tutorial shows us a good way to implement models. In the tutorial, they implement an ORM approach to the models, wherein you would create three filesóthe actual Model, which is an abstract representation of your object; a Mapper, which maps data from the database to your Model; and a Database Table object, which is used by the mapper to get the data. You can check out the code in the ZF Quickstart tutorial, where they used this approach to implement the model of a simple Guestbook application.

For those asking “Why do I have to code this myself while other frameworks do the work for me?”, this is a perfect segue to my next reason…


Reason 6. Integrate with Whatever you Want!

Zend Framework’s decoupled nature makes it very easy to integrate other libraries that you want to use. Let’s say you want to use Smarty as your templating system. It can be done by simply creating a wrapping class for Zend_View_Abstract, which uses a Smarty instance to render the view.

This works both ways, as you can integrate ZF into other libraries as well. For example, you can integrate ZF into Symfony. They’re planning to do this with Symfony 2, using the Zend_Cache and Zend_Log components from ZF.

Example

For our example, we’ll try using Doctrine to implement our Model. Continuing from our site example above, say you’ve already implemented your DB table like so:

CREATE TABLE  `site` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `url` varchar(100) CHARACTER SET latin1 NOT NULL,
  PRIMARY KEY (`id`)
);

To integrate Doctrine into ZF, we’ll have to make sure that the proper settings are defined. I’ve followed this tutorial from dev.juokaz.com about using Doctrine with ZF.

Assuming everything works out, you’ll just have to generate your model files by running the doctrine-cli.php php file from the tutorial like so:

php doctrine-cli.php generate-models-db

You should see this success message:

Afterwards, you can check the folder which you set as the place to store the generate Model classes.

Then in our controller class, we can simply use our site model class.

<?php

class IndexController extends Zend_Controller_Action
{

    public function indexAction()
    {
		$siteform = new Form_Site();

		if( $this->_request->isPost() && $siteform->isValid($this->_request->getPost()) ) {
			//stuff to do if the input is correct
			$site = new Model_Site();
			$site->url = $this->_request->getParam('siteurl');
			$site->save();
			//redirect to our success page
			$this->_redirect("/index/correct");
		}
		$this->view->siteform = $siteform;
    }

    public function correctAction()
    {
		// Yay, we're re-using our Form_Site object!
		$this->view->siteform = new Form_Site();
    }
}

If we check our sites table, we’ll see that our records is there

Now, every time we submit a site, our controller will use our Doctrine model implementation to save to our database. Isn’t that nice and easy? Setup may be a bit complicated, but on the plus side, our project is now able to take advantage of a tool which has been developed specifically for Model implementation. Our project now has the power of two very developed technologies behind it.


Reason 7. Guidelines and Standards

Zend Framework is developed in conjunction with a very extensive Contributor Guide, which basically states that:

  1. Every contributor for both documentation and/or code, at any level (either a few lines of code, a patch, or even a new component) must sign a Contribute License Agreement (CLA).
  2. Code MUST be tested and covered by a unit test using PHPUnit. And…
  3. Code must adhere to strict Coding Standards

These strict guidelines ensure that you only use readable, high-quality code that has been tested thoroughly.


Reason 8. All Code is Guilty Until Proven Innocent (aka Test-Driven Development)

Image courtesy of http://www.codesmack.com/

Test-driven development is a programming technique that requires a developer to write tests for the function he is supposed to code before writing code for the function itself. By writing the tests first, it ensures that the programmer:

  1. Thinks of the possible use-cases of his code
  2. Creates a whitelist of input and output
  3. Makes it easier to refactor his code
  4. Makes it easier to pass code from one person to another

The test-driven development Cycle
Image courtesy of Wikipedia

Zend Framework makes it easy to do TDD via Zend_Test, which uses PHPUnit, a popular unit testing framework. PHPUnit lets you test not only your Controllers, but also your library and model functions. To add to this, Zend_Tool, which is Zend Framework’s scaffolding utility, already makes provisions for PHPUnit when you use it to create your project.

Integrating PHPUnit and Zend Framework

Setting up Zend Framework and PHPUnit is not that difficult. Basically, once you’re done with it, you’ll be able to use the same setup for your future projects. Just as a side note, the following steps assume that you’ve used Zend_Tool to scaffold your project structure and files, but it should be relatively simple to change for other setups.

First, we need to install PHPUnit. The best way is to install it via PEAR:

pear channel-discover pear.phpunit.de
pear install phpunit/PHPUnit

Afterward, we’ll open our phpunit.xml, an XML file generated by Zend_Tool. You’ll find it inside the tests folder in the root directory of your project. Add the following lines:

<phpunit bootstrap="./TestHelper.php" colors="true">
    <testsuite name="Zend Framework Unit Testing">
        <directory>.</directory>
    </testsuite>

    <filter>
        <whitelist>
            <directory suffix=".php">../library</directory>
            <directory suffix=".php">../application</directory>
            <exclude>
                <directory suffix=".phtml">../application</directory>
            </exclude>
        </whitelist>
    </filter>
</phpunit>

After saving phpunit.xml, create a new file inside the same folder as phpunit.xml called TestHelper.php. This PHP file will help us setup the environment for our tests.

<?php
// start output buffering
ob_start();

// set our app paths and environments
define('BASE_PATH', realpath(dirname(__FILE__) . '/../'));
define('APPLICATION_PATH', BASE_PATH . '/application');
define('APPLICATION_ENV', 'testing');

// Include path
set_include_path(
    '.'
    . PATH_SEPARATOR . BASE_PATH . '/library'
    . PATH_SEPARATOR . get_include_path()
);

// We wanna catch all errors en strict warnings
error_reporting(E_ALL|E_STRICT);

require_once 'ControllerTestCase.php';

We then create our parent Controller Test Case class, which all of our Controllers will extend. This will help implement methods which would usually be the same throughout all of the Controller test classes.

<?php
require_once 'Zend/Application.php';
require_once 'Zend/Test/PHPUnit/ControllerTestCase.php';

abstract class ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
{
    public $application;

    public function setUp()
    {
        $this->application = new Zend_Application(
            APPLICATION_ENV,
            APPLICATION_PATH . '/configs/application.ini'
        );

        $this->bootstrap = $this->application;
        parent::setUp();
    }

    public function tearDown()
    {
        $this->resetRequest();
        $this->resetResponse();
        parent::tearDown();
    }
}

Lastly, we create a controller test class:

<?php
require_once realpath(dirname(__FILE__) . '/../../ControllerTestCase.php');

class IndexControllerTest extends ControllerTestCase
{
    public function testCallingRootTriggersIndex()
    {
        $this->dispatch('/');
        $this->assertController('index');
        $this->assertAction('index');
    }
  
    public function testCallingBogusTriggersError()
    {
        $this->dispatch('/bogus');
        $this->assertController('error');
        $this->assertAction('error');
        $this->assertResponseCode(404);
    }
}

All that’s left is to run our test. Open your command prompt and go to the tests folder and type:

phpunit

Your command line should output the following:


PHPUnit and Zend Framework setup tutorial and code courtesy of http://www.dragonbe.com

Reason 9. Community and Documentation

Due to its multiple components, complexity, and fully object-oriented approach, Zend Framework has a very steep learning curve. It becomes easier to learn due to the comprehensiveness of its documentation and its thriving community. First of all, the Zend Framework Programmer’s Reference Guide boasts a complete guide to all ZF components, with examples, code, and usage theories.

Aside from this, there are a lot of blogs out there that share Zend Framework tips and tricks. For example, Phly, boy, phly, the blog of Matthew Weier O’Phinney, a Core Contributor to Zend Framework, provides a lot of insights, clever uses, and component explanations for Zend Framework. Zend also has a site called Zend Developer Zone, which aside from publishing tutorials for Zend Framework, has stuff like Zend Framework Webinars, podcasts, and articles about PHP in general. Another site, called Zend Casts, offers a lot of useful video tutorials on different Zend Framework components as well. Last but not least, there’s a free online book called Zend Framework: Surviving the Deep End” written by P·draic Brady, another Zend Framework contributor.

As you can see, there is no lack of support from the community, the documentation, and the developers. If you have any questions or need any clarifications, a quick search with the right keywords should almost always give you relevant results. If not, there’s still the Zend Framework Mailing Lists, the official Zend Framework Forums, the unofficial Zend Framework Forums or the unofficial Zend Framework IRC channel


Reason 10. Certifications Ahoy!

If you’re still unconvinced about learning and using Zend Framework, this reason is actually the one that I feel most distinguishes Zend Framework from all the others. Zend not only offers Zend Framework Certification, but PHP Certification as well. By offering certifications, Zend helps you use your expertise in PHP and Zend Framework to boost your portfolio or CV. The Zend Certification site lists a number of reasons to get certified, some of which are:

  1. Differentiate yourself from competitors when looking for a new job
  2. Get your resume/CV noticed
  3. Have your profile displayed in Zend’s Yellow Pages for PHP Professionals
  4. Be part of the Linkedin Group Exclusively for ZCE’s
  5. Get special discounts on Zend PHP conferences worldwide

Addendum

Just to keep things balanced, here’s a quick list of reasons why you might not want to use Zend Framework:

  1. VERY steep learning curve. It’s not very hard for advanced PHP users, but for beginners, there’s a lot to learn!
  2. Big footprint. Since Zend Framework has a lot of components, it’s total size is relatively higher than other Frameworks. For example, CodeIgniter’s system folder has a 1.5MB footprint compared to Zend Framework’s 28MB footprint.
  3. No solid scaffolding tool. Although Zend_Tool offers some functionality, it’s not much compared with the scaffolding utilities of full-stack frameworks like CakePHP or Symfony.
  4. Not shared webhosting friendly. The folder structure generated by Zend_Tool suggests that the public folder be the only directory accessible via http ó which assumes that a user is able to create a virtual host for the project. This is something you aren’t able to do in most shared web hosting environments.
  5. Too gluey. Since everything is in separate classes, it’s sometimes hard to envision how everything works. This wouldn’t be a problem with full-stack frameworks, since they mostly take care of everything for you. Without Zend_Tool, it would be extremely difficult to set up a working project structure

Conclusion

A lot of advancements have been made in the world of PHP Frameworks in the past few years. I’ll be honest, there’s a whole lot of fish in the sea. There are frameworks like Codeigniter, CakePHPand Symfony which are also good to use. Some of you might be thinking, “Why did this guy focus on Zend Framework? Why didn’t he run performance tests to compare the different frameworks?” To that, I reply with this quote from a very entertaining article entitled “PHP Framework Benchmarks: Entertaining But Ultimately Useless” by P·draic Brady:

To create a positive benchmark, you need to understand that all frameworks were born as festering piles of unoptimised stinking crap. They were all born bad and get worse with age. This sounds quite sad, but actually it’s an inevitable compromise between performance and features. It’s also a compromise between performance and ease-of-use. So you see, performance is unfairly faced by two opponents: features and ease-of-use. All performance is sacrificed in the name of serving the needs of rapid development, flexibility, prototyping, and making your source code look prettier than the other guy’s. As if.

What happens if you move away from the enemies of performance and do some propping up behind the scenes? You get…wait for it…oodles of extra performance!

When it comes down to it, which framework you choose to use really depends on how comfortable you are with it. None of these frameworks would be of help to you if you aren’t able to take full advantage of their features. You can spend weeks or even months using a specific framework, only to trash it in the end because you just aren’t as comfortable using it as you were with some other framework.

So I invite you to at least try out Zend. If it works for you, that’s great! It does for me. But if it’s not a good fit, go ahead and try out the others. Soon enough, you’ll find the framework that’s just right for your needs.

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.thomasv.nl ThomasV

    I still fancy Code Igniter above Zend Framework,

    I believe it’s an easier platform to develope php applications than Zend Framework, but still heck of a nice article!

    • http://nikkobautista.com Nikko Bautista
      Author

      Thank you very much kind sir! :)

      • leon

        Thank you

    • http://www.fluxwise.com Tim

      Of course codeigniter is one of the best lightweight OO-frameworks around! Zend is nice but it’s too expensive and too unwieldy to make the average webapp. Zend is nice if you have too much money to spend on certified developers. Succes guaranteed?! I think so … with codeigniter ;-)

    • http://codefight.org Damu

      same here Thomas. I tried to get out of CI ring but always stuck there because i love to work with CI then any other frameworks out there.

  • www.phpfeeds.co.za Ronald

    I tried learning the Zend framework about 2 yrs ago, but got stuck and there was not much documentation at the time which has now improved, I am now currently using symfony which has excellent documentation but I still use some of the library files from the Zend framework which is very easy intgrating to symfony(thanks to the decoupling in the zend framework). Overall the framework is very good once you know how to fit things together , but they need to put more effort on the documentation and have books like like symfony which teach you how to build your own project from start to end before dropping you half way.

  • http://simononsoftware.com Simon

    Yea, nice summary, but sometimes it is just easier to use simple PHP instead of learning a framework.

  • http://codefight.org/ Damu

    Gr8 article. Thx 2 James who fwded this link to me. I use codeigniter & trying to create CMS with it. But due to magento i was/am forced to use Zend. After reading this article i feel like using zend in other projects as well rather than just learning to work with magento only.

  • Sophy

    Hey verybody ZF, CI, Cakephp and other php framework base on PHP. They are good other place….

  • http://froskie.com Froskie

    Dispite of the huge names that ZF tries to use by default, like: Application_Model_DbTable_Books_Mapper or something like that, I’ve always loved ZF. Use it since version 1.2 when it was really buggy.

    I like the fact that you have really REALLY several libraries already integrated to the main stack, so you dont need to search for 3rd party plugins, etc.

    I’ve trying to integrate the doctrine now, ’cause I believe such combination will be the most powerfull.

    Anyway, great article, gonna send to my Cake and Symf friends… =]

    • http://nikkobautista.com Nikko Bautista
      Author

      Check out the tutorial I mentioned about integrating Doctrine with Zend, it’s really useful and works with the latest versions :)

  • http://www.evanbyrne.com Evan Byrne

    I find it hard to justify using a 28MB PHP framework that doesn’t even support full MVC. I see a lot of people using it as more of a toolkit than a framework. Just including one or two things they want from it into another framework.

    • b

      It does support full MVC, the ‘M’ part is up to you though, because a model can be absolutely anything, so it’s not worth extending an existing class, because that class would have to encompass a ridiculous amount of things.

  • http://wilmoore.com Wil Moore III

    Great article. It is hard to quantify the usefulness of this type of framework/library to those that essentially don’t and may never need it; however, for those that need (you’ll know you need it when you need it) the flexibility, testability, and scalability it is awesome.

    Yes, ZF is probably one of, if not the closest framework in PHP to something like Spring in Java or Django in Python; however, tools like this exist for a reason.

    -Wil

  • http://www.edwardyarnold.co.uk Ed Yarnold

    I think Zend Framework is great and wish I had the time to write my own model implementation for it. But at the moment the main selling point of frameworks to me other than encouraging DRY and MVC is that it speeds up Creation, Reading, Updating and Deletion of the data – in most php web apps that’s all you really ever do. CakePHP (my current framework of choice) speeds that up tremendously well, and it’s built in validation is great.

    • http://www.omaroid.com Omar Abdallah

      I’ve used ZF for an enterprise project, and was forced to use cakephp for the last 6 months. I love the DRY approach of Cake that was almost copied from Rails. but the cakephp ActiveRecord is just too messy, Whatever you do, arrays can’t compare with objects, I’ve used Zend_Db and I love how you can treat model data and play around with your architecture. Something that I always loved with both cakephp and rails, are the hooks beforeSave, beforeRender, BeforeFilter… Which I’m not sure they all exist in Zend.

      Cakephp also provides an enormous space for putting the database against the wall by fetching all of all related models with a single find. that will take you some time to filter what you want and what you don’t want.

      I prefer ZF for its OO approach which is more concise than cakephp. So I’m moving back to ZF in the next project and I’m currently evaluating some scaffolding tools. So I can get to develop as fast as I did with cakephp scaffolding functionality.

      I’m also evaluating doctrine with ZF, and I want to come up with a strong solution that combines doctrine and scaffolding with ZF. Hopefully I would achieve that.

      If anyone has got any suggestions in my current area of research please point me.

  • http://www.seneweb.com Salam Fall

    I tried ZF since it’s early version, and have always found it to be Bulky and Painfully slow, as a matter of fact I have tried at least 5 Major php Framework and found allof them to be lacking Flexibility, but as a result of looking under the hood I developed my own framework and it’s light a feather, and from time to time I pluck from the Zends array of classes to do particular tasks. Also great article.

  • http://harikt.com Hari K T

    Great . When I come to learn ZF without any knowlede in MVC ( some months back ) , it was really hard. I want to admit a fact that symfony docs was a great one to know how the MVC framework works at that time.
    But today the ZF docs has improved a lot.
    Hearty congrats to the ZF community . Your Addendum is true :) . Great post dude .

  • http://www.buitenaardig.nl/ Phil

    This goes WAY above my head :c

  • Ravi Ahuja

    Nice tut..!!

    But any1 can tell me that what is the advatage using framwork while i can do this by using oop as well without anyframework.. & while along with any framework there is the disadvatage also which is take more time execution.

    SO why should we use framework??

    • andy

      So you dont have to make your own. Any decent site needs some kind of organization and architecture. You will end up creating your own mini-framework anyway. Why bother with that. Main advantage of out of the box frameworks is for RAD. You can make your own wheel. Sure why not.

  • http://www.jsxtech.com Jaspal Singh

    Great Post on Zend Framework.
    Thanks for sharing.

  • http://www.creationnext.com Abdul Raheem

    Thanks! Nice post.

  • http://www.excalibur-design.be Cheng Alain

    hey

    A year ago, i tried ZF at my previous company. I found it to much work to get some results and hard to learn.
    Finally i gave up after a few days.

    In march 2010 i went to a new company.
    I’m obligated to work with ZF.
    I wasn’t sure it will work, because i already gave up ZF once.
    But after following Rob Allen’s tutorial http://akrabat.com/zend-framework-tutorial/ , it all make sense.

    I’m hooked now :)

    btw: great article

  • MP

    I’m sorry, but I think someone must be confused here.

    I’ve been using frameworks such as CI, CakePHP, and ZF equally for years and the 10 reasons above are complete BS, especially #9.

    ZF is by far the worst documented framework available. Nearly every example is vague in its description and offers incomplete code examples with references to code that isn’t displayed any where on the site.

    Additionally, ZF has changed so drastically over the last few years and they provide NO documentation as to what is deprecated and what is still in use. This results in hundreds of people posting code for different version and most of it is unusable by anyone.

    Once you become accustomed to the great documentation of CakePHP and CI, and the ease of use, you quickly realize how crappy ZF really is.

    Let ZF die, I think zend wants that anyway as ZF is their greatest failure.

    • SalmanAbbas007

      Very true. :|

    • SolidSquid

      Lack of documentation => More people needing training in the framework. Along with tech support, this is how most profit-driven open source projects earn their bread and butter. Not saying this is the only reason for it, but it certainly wouldn’t encourage them to improve the documentation

    • Rob

      People talking shit about ZF just because they are to lazy, or they don’t understand real OOP.

      ZF is such a great framework, but for real professionals. ZF is freedom, ZF is flexibility. and Zend 2.0 will be a true beast.

      I won’t recommended it to newbies, because their gonna feel frustrated and then start talking shit.

      I’m currently working with ZF with Doctrine, and believe me, it has been the best experience ever.
      A robust application with more than 1,000,000 users, around 500 modules, and very fast and easy to maintain.

      10 programmers working on it. The team is very happy. Some of those programmers coming from Ruby on Rails, CakePHP, Symphony, etc.

  • Brendan Sheehy

    To understand the benefits of Zend in my opinion you really need to understand the OO paradigm and general best practices. Don’t try to learn Zend if you don’t understand the OO paradigm. If you understand the OO paradigm the notion of Zend and what it is trying to achieve it is very easy to pick up indeed.

  • http://wilmoore.com Wil Moore III

    I’m not sure where MP is coming from…he/she simply sounds disgruntled. At any rate, I would add that many of the concepts employed by ZF are portable to other platforms/environments. Rails, Django, .NET MVC2, etc.

    If you care about that portability of skills then you have another reason to consider ZF. If you will only ever work with PHP and nothing else (really?), then by all means, ZF may indeed be a waste of your time, so you should forget about it :)-

  • Web dev

    I freaking hate zend.
    Trying to adjust a site someone made in it and the documentation is worthless, the support has no response. On their own documentation they don’t even list the files they are talking about but they ramble on and on about code. WORTHLESS – NEVER USE THIS MESS OF A SYSTEM. IT WILL ERROR ON YOU EVERY OTHER DAY!@!!!!!!!!!!!

  • http://www.inventador.com.br Renato

    Hello,

    I have developed PHP using Zend Framework for approximately 3 years, day by day.
    What have i learned? A lot. About OOP (even that in the past i though i already knew everything), about ZF Classes, and about Patterns.

    Patterns are really valuable for me as a programmer, and ZF showed me a lot of ways of how much patterns are important to develop AND MAINTAIN web applications.

    In a practical way, doesn’t matters what language or framework do you using to develop web applications, what really matters is your how much is your efforts and commitments to solve the problem proposed.

    Considering bussinness logic, doesn’t matters if you using Pure PHP, ZF, Code Igniter, Ruby on Rails or Java, and know about Code Igniter wont make you better than a programmer that only knows pure PHP.

    Sometimes, you have to use your mind before using a language or a framework.

  • Vincenzo

    You forgot the Main Reason: it’s more complicated to create an application based on Zend Framework, but it’s 100 times easier to maintain it when you have to make little changes in data presentation, logic, access permissions, grabbing data from external websites, etc every day.

    I would say, a website created in Zend Framework proves that php is an enterprise level language now.
    A typical php website with sql statements interspersed in html looks very amateur, and it’s the reason “serious programmers” laugh when you mention php.

    Footprint? ZF uses autoloading, even all your own classes are autoloaded. That means you never load classes that you never use during a call. But it’s nice to have an existing class that can create a pdf file or connect to an external website…

  • andrei

    I finally switched from Codeigniter to Zend. It definitely was a lot of things learn. I was almost giving up at some occasions. Documentaiton is really awful.
    Codeigniter is a breeze in terms that you never really have to look at framework source code and docs are better. However – at some point CI becomes way too limiting.
    Also – CI abstracts away many concepts that any respectable developer should know: dispatch, router, response/request objects. ZEND classes are thoroughly tested and very reliable. I haven’t seen CI utilizing interfaces and abstract classes at all by the way.

  • http://www.devanagarifonts.net Mohit

    I have been using ZEND for quite long time and am totally satisfied with it…It is easy to learn and develop.

  • http://seductiveturtle.com Aaron

    I actually want to point out another strength of Zend Framework.You are actually able to use whatever directory structure you want with some configuration, which in turn means that you do not need to use a “public” folder

  • http://www.thetennishub.com/pg/blog/mvcxaeym2492/read/142240/article0407531 Jacquelynn Peteet

    I genuinely liked the submit and fantastic tips..even I also think that tough work will be the most essential element of obtaining success maintain it up :)

    • http://www.facebook.com/profile.php?id=100000494066559 Ben

      But where to write this jQuery code ..like write this code into a .js file and inlcude it in our view file using tag ???

  • http://www.ednevnik.si/?u=izdelavaspletstrani izdelava internet strani

    Nice overview, now it is time to try it? Does it have a long learning curve?

  • Phanor Coll

    excellent review, I’ve been using ZF for a while now, I don’t use anything else for my developing process. a most have for every serious developer..I truly recommend it..

  • http://www.cleantags.com sergiu

    I have been developing web apps in CI and Yii for 2 years and recently switched to ZF….and all I really have to say that CI is kitty pool compared to ZF, I don’t understand why people bash ZF, which is by far the best framework, and makes PHP comparable to other languages. CI has a bad implementation of a domain model and for a large scale web app that could prove very faulty.

  • http://terrariacrack.com/ terraria crack

    Once I originally commented I clicked the -Notify me when new feedback are added- checkbox and now each time a comment is added I get 4 emails with the same comment. Is there any approach you possibly can take away me from that service? Thanks!

  • http://www.freenepalisongs.com Prakash Parajuli

    Thanks. It was of great help but is too difficult for beginner.

  • http://ocsdev.org Kyle DeFreitas

    I can safely say this is the best description of using Zend Framework. It has given me a different appreciation for the zend framework.

    Much thanks

  • Alex

    I read this article about 6 months ago while exploring MVC and frameworks and found it very helpful. I just re-read it and pulled out even more!
    I ended up ruling out CI and Cake in my framework search because I found them to be too tightly wrapped, and I only learn by doing. I ended up building my own mini-framework and utilizing portions of ZF, especially their DB classes, although I hit many stumbling blocks while learning it due to their lack of decent documentation.
    The ONLY thing that saved me was wonderful tutorials (like this one) provided by generous developers who also use ZF.
    Thanks for this great article.

  • http://www.kevaldomadia.com/ Keval Domadia

    Epic explaination is epic.
    You sir! Have convinced me. :-)

  • http://www.atlantic8.com Christof Coetzee

    I would just like to mention a very important thing about Zend Framework and standard hosting.
    The out-of-box public directory ZF uses can easily be changed to the normal web root, you can just move the index bootstrap file into the web root and then change its settings.
    Also I’m hosting many ZF applications on standard hosting and has never had any issues with system requirements.

  • http://www.prosatya.com Satya

    Nice articles. this articles force me start thinking about zend framework again and build your product in Zend framework.

  • http://techiesindiainc.com/ Zend Framework

    How about Yii Framework, is it good to use ? And Anybody worked on Yii Tutorials before.

  • http://www.hq40k.com Inxentas

    Good read, and I agree. Zend Framework is usefull because it speeds up my development time by tenfold. getting into the framework may be a bit daunting and will take a lot of research, but it pays off. Zend doesn’t need concrete models, because there is so much goodness to extend. I can’t imagine myself working without Zend_Db_Table, Zend_Validate and Zend_Translate anymore! I can truly focus on the business end of an application, and let the framework take care of the low-level jobs.

    • John

      You clearly never used any others framework to saying that

  • ImpaphSmapy

    Who and where to condense this summer on festival, share your information.

  • herve leger homme

    However, each lady has her own destiny. Temecula exterminators also find this to be true in the communities they serve. The basic premise of a Luxury Yacht Charter to the Italian and French Riviera is to take in the ambiance of these places, nevertheless Croatia as well as Turkey offer ample opportunities to escape from the monotony of everyday life.

  • Romin

    MORAL OF THE STORY…
    This shit makes simple things more complicated and there is no benefit of using it.
    For example… if you want to make a simple form you have to write dozens of lines and mess with object oriented things to finally get a form with few inputs.

    • vlado

      It will be easier to maintain your code even after months. And if anybody else will look at your code, he will know what is happening there.

      But I agree with you: “his shit makes simple things more complicated”. It’s terrible using this.

    • hfhh

      u r too arrogant

    • http://www.facebook.com/asifsaif90 Aasif Saifuddin Auvi

      right you are :p but for enterprise support zf2 will be fine

      • Hizam Mohd

        u just said the ‘E’ word.

    • Jeremy

      “It will be easier to maintain your code even after months…” => Heu not at all. I’m force to work on Zend in my office and I’m actually working on someone’s project and for sure I can tell you, it’s everything but easy to maintain. Now it’s just a bunch of crap. Doing all the application from scratch will take me less time than deal with the actual mess.

  • brandon

    I’ve created an easier to use version of Zend that includes some of the most popular features that one would implement. Its available for free and takes less than 2 minutes to get setup and running. Here’s the link to the installation instructions: http://www.brandonswift.net/swiftzend/

  • http://www.facebook.com/asifsaif90 Aasif Saifuddin Auvi

    For Rapid Development I will prefer Light weight frameworks Like Laravel PHP framework. Codes are very much readable and expressive :) . ZF2 has changed a lot in architecture

  • http://www.creativethemes.net/ Creative Themes

    Magento also used Zend framework, it does have pros and cons, the big thing is the steep learning curve invovled in it.

  • http://www.hiddenbrainsindia.com/ Brian Parker

    Nice post!! I like Zend Framework. You describe true reason, but there are also some “not to use” reasons like its performance, etc. ZF is good framework for enterprise products such as Magento. What do you think
    about this?

  • Jeremy

    So far, except for the certification part, you only describe what any other frameworks, better than Zend, have as well.

    I was a Rails developer for many years and for the needed of some projects, I must go back to PHP. Since, I’ve tried many great Framework such as Laravel, CakePHP or CodeIgniter.

    It’s now about 8 months that I use, despite me, Zend Framework and the only thing I can tell about it is “Waist of time”. The purpose of a framework is also to allow developer to build quickly an application and no matter how big the application is, keep a maintainable structure/architecture.

    With Zend, it’s almost impossible to have the 2 points I described above. The bigger the application is, the more messy it become.

    Also, the big point makes me NOT to choose Zend as a decent solution is the lack of their Model. Basically, for any new projects, I clearly have impression to “Reinvent the wheel”. Just for simple methods as CRUD need to be write by the developer again and again and again : Waist of time.

    That was my point of view about that. Most of programmers I know who use Zend say “Zend is the best” but most of them never used any other framework. How can they compare?

    Now, my advice is, try Zend, BUT NOT JUST Zend. And then make your choice with the framework who fits you.

  • Tyler

    I’m using Zend in my company for a big project and I’ve recently needed to create a slug for an article, a SIMPLE slug.
    So I looked over the internet and into the Zend doc to see how to do. Guess what???There’s no such class or utilities in Zend. You have create a helper on your own to achieve this.

    WOW!!!!That was a big shock. Everyone, at one point will need to create a slug. But I’m sorry, a web framework not able to create a slug for you is like a car without wheels.

    I was going to create such a class/helper and then I realized that, CakePHP have a good utility class (Inflector) who can do that. So I installed it in my project.

    My point is, and I say that to everyone who dare say “Zend is the best”, if everytime you need to do something, even though it’s a little tiny thing that any good framework should have built-in, but you have everytime to spend 1-2 hours to create yourself the utility you need, it’s just useless and a waist of time.

  • http://www.facebook.com/komal.banga.90 Komal Banga

    If you are a beginner and searching for best php framework you should first know what exactly php framework is then it will be easy for you to choose framework for you.
    http://iwebeffects.com/what-is-php-framework-how-it-works-and-which-one-you-should-use/

  • http://www.facebook.com/erling.loken.andersen Erling Løken Andersen

    Our large-scale web application http://www.listnerd.com uses the Zend Framework 2.0. I really recommend it for large-scale web applications with short development cycles. With Zend, we’ve been able to cover a lot more ground than we otherwise would have.