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.

Add Comment

Discussion 159 Comments

Comment Page 1 of 21 2
  1. Rik de Vos says:

    Cool!

    First comment btw

  2. Michael says:

    I’m using Zend on a project here at work and I must say; It’s quite extensible.

    First comment: w00t!

  3. Rilwis says:

    Sounds a good framework. I’ve heard a lot about Zend when I first coded PHP. But is this a big framework? How about its load? (in compare with others like CakePHP, Symphony and CodeIgniter).

  4. Tim says:

    How about a comparison chart between zend / cakephp / codeignitor / etc. (codeignitor is my choice..also have invested a bit of work and projects recently).

  5. Daniel S says:

    Zend FW is too heavy and quite to much. If i write i PHP Application, i want to do it fast. I have no time to see which class is the parent class from that, and where the abstract class for class XY is. And – sorry for that – I would never use an Framework with ~30MB files in core Folder.

    The best FW is the self-written Framework!

    • Tom Schlick says:

      When working with a team a self made framework is usually a bad idea. If you use a standard framework such as CodeIgniter you can bring people on and have them instantly know how the underlying structure works without hours and hours of training. Also, you have a community of people who will find and fix bugs so you dont have to encounter them.

      That being said, a huge framework is more of a burden than it is help. I for one use CodeIgniter with my team and it works fantastically. If we need something Zend offers we load that one class as a library. No need to have 30+MB in your repos.

    • djheru says:

      I can appreciate your concerns, but using a good IDE like netbeans or zend studio will eliminate a lot of those issues. And as far as the filesize – if you just stick the library in your include path, you can use one copy for multiple projects with no problems.

    • With ZF I have definitly something going faster than you without. Zend makes it possible to write less code and do more with it.

      I allways thought (just like you) that a ‘home-made framework’ was better, only know I know how wrong I was. (Though there is some learning curve here).

    • Wow, ~30 MB in core?? I heard Zend was very slow, so I’ve never tried it. If it is 30MB or 1MB, if it’s slow I’m not going to use it!

    • Author

      For a simple or even a medium-sized application, I agree, you shouldn’t be wasting your time using Zend Framework, even any framework. For that scale, a self-written one is usually good enough.

      Using a self-written framework for a big application is something I don’t agree with though. You would just be re-inventing the wheel by creating your own FW, which will probably increase your development time, as opposed to just plucking in something like Doctrine to handle your database interactions.

  6. Darren says:

    I agree with Daniel. I have integrated Zend Framework with some other projects and it is too large. Take not I am a ZCE so I am not just saying it. I like Code Igniter for normal projects and Symfony for large web apps.

  7. Ignas says:

    That’s what I’m calling nice article! Nice one about really nice one framework. Forget frameworks whose are still in PHP4 (CI for example) and use normal one! More about Zend please! This article helped me to solve one big problem for me (I just found the idea here). So thank you!

    • Tom Schlick says:

      PHP4 is supported currently with CI but if you are running PHP5 it loads a separate class that is optimized for PHP5. Also CI 2.0 (which is currently under development and mostly stable) is deprecating PHP4. Plus you can load zend classes through it as a library. Zend is too bloated.

    • Author

      Thanks for your compliments! I intend to write more about Zend Framework on Nettuts+, so stay tuned ;)

  8. jack says:

    theres also flash remoting…dont forget about flash remoting :)

  9. Rode says:

    ZF is ok, but i found that it looks pretty weak compared to Rails in terms of quality and development speed. Of course if you have to use php Rails is not an option.

  10. Petar Moskov says:

    I use Codeigniter. It is easy to learn, flexible and powerful.

  11. Carlos says:

    Nice Post about ZF, but I think the 5 reasons why you might not want to use Zend Framework are THE reasons for not usign it.

    I don’t understad why every time that someone wants to compare PHP frameworks CI is always treated as a bad framework just because it’s supports PHP 4.

    Here you can find a very good explanation WHY CI supports PHP 4 along with some really good points of view…

    http://www.derekallard.com/blog/post/codeigniter-will-not-be-dropping-support-for-php-4-anytime-soon/

  12. I’ll stick with CodeIgniter :)

    • Purple says:

      Same here. From what I have read, you can actually use Zend FW components in codeigniter (like Zend Auth). I wanna give that a try.

  13. aryan says:

    I wish a Zend Framework series on Nettuts like CI.

    Seems first article to support ZF.

    Thanks!

  14. You state in your article that ZF has no ‘M’ of MVC, but what would you call Zend_DB? I have never heard of Doctrine before, but as far as I can see, they can do about the same?

  15. Allso you state that ‘it’ does not work good with Shared Hosting, for myself I have not used it on anything other than shared-hosting, it works great, you can ‘put you index.php’ outside the public folder, and close every ‘application and library’ folder down with .htaccess, only allowing index.php and the ‘public’ folder.

    • Niels van der Kam says:

      Same here. Zend Framework works perfectly fine with Shared Hosting. You work with .htaccess files. Therefor there is ofcourse the risk of making an error in one of the .htaccess files and exposing the code / sensitive information.

  16. Dave says:

    I’ve asked Jeff a few times if he wants some stuff with zf but never really been required. It’s a fantastic framework. I’ve actually found it very hosting friendly as long as you have access to more than just the public root. Every shared host I have used gives you that. Also there is an M in Zend_db. Which uses table gateway. Very verbose code used in that pattern. However version 2 will include Doctrine as the frameworks ORM. And if you really want you can integrate doctrine 1.2 right now, loads of tuts on the web for it.

  17. Nice overview to ZF. I’d also like to point out the emerging roadmap for the next major version of ZF 2.0. It address several of your “gotchas” at the end of the article. It will also take coding standards and uniformity of code to an even higher level.

    More information here: http://framework.zend.com/wiki/display/ZFDEV2/Zend+Framework+2.0+Requirements

  18. Ignas says:

    Just don’t forget one thing… If CI supports PHP4 so it means that no PHP5 functions was used. And what it means? It means that newest and powerfull PHP engine is not sed there, just because they don;t want to rewrite everything on the PHP5 and still stucks on the PHP4 which is way too old and doesn’t support real OOP. Of course if you like it, use it, but one day you will face big problems. It’s everyone’s choise :)

    • I think this is like saying that echo or include is going to be deprecated, which is foolish. Just because CI doesn’t use public,private, __construct, etc. doesn’t mean it’s going to break anytime soon. As of CI 2.1, CI will be php5 only.

      • Alejandro says:

        Hey man, don´t forget split, actually it´s deprecated and some CMS and frameworks have problems with that.

  19. Khaled says:

    Well ZF is a good one but i realy like CI cause no configuration no boostap just download an start the magic

    • khaled says:

      One other thing there is not a really good in depth tutorial lets you get started

      • Ignas says:

        Yes.. ZF fails on documentation which is needed when you just start.. even if you already know what you’re doing, the documentation lacks…

      • Author

        Yeah, it’s not really what I had in mind when I wrote the article, it’s just to help people who are a bit undecided as to what framework they should use for their next project.

        Stay tuned though, I’m sure we’ll be able to give a very in-depth article on using ZF soon!

    • Kevin says:

      When you start to develop commercial/enterprise apps, you will run into problems with CI. It’s good to learn MVC with, but move on quickly to a more industry powerful framework. I found Kohana a good bridge from CI to start exploring other frameworks

      • Khaled says:

        Well I use CI for small project but for commercial/entreprise apps ASP.Net MVC is the one (.Net)

    • Author

      Like I said, the most important thing when choosing a framework is how comfortable you are with it :) No matter how fast, feature-filled and great a framework is, it will be useless if you’re not comfortable using it. Kudos to you for sticking up for your choice of framework :)

  20. Enterprise level development demands this type of framework and testing suite, a small two store company does not require a bazooka to squash an ant!

  21. Ivo Trompert says:

    If you like Zend Framework and you want to start in developing white it you must take a look at: http://zendcasts.com/

  22. Kevin says:

    So glad to see a framework other than CodeIgniter being mentioned!

    Zend is a really, really good framework. Would love to see more tutorials on Zend.

    Also, check out http://www.yiiframework.com. I’ve been using it a lot lately, and it’s equally is powerful as Zend with less footprint.

    • Drazen Mokic says:

      Yii ist very powerfull and not that bloated like Zend. I iuse CodeIgniter and i like it very much but it depends on the project. Use the right tool for the project, not the other way.

  23. Sk1ppeR says:

    Sure…a framework with 15mb footprint (zend) is way better than one with 3mb footprint(codeIgniter/kohana)…so yeah…

    PRO -
    it’s powerful OOP framework…

    CON-
    15mb per user is a lot of ram

    My suggestion…wait for codeIgniter 2.x

    • Author

      The big footprint shouldn’t be a problem with ZF2 as well, since it will strip all requires and implement some sort of preloading. This can also be done with the current ZF as well, although not as easy.

    • commenter says:

      Sorry I forgot your a profesional PHP developoer who makes enterprise solution.

      Who are you to come with a suggestion, jheeze :/

      • Sk1ppeR says:

        Tbh, I am professional PHP developer and i do provide make enterprise solutions. Though i don’t like working with clients i do my own websites and users pay in them and in none of them i’ve used zend framework. Most are with native code without frameworks, some have been made with codeIgniter mainly because sometimes i’m really lazy :) I did some test projects with kohana and cakePHP and tbh i enjoy CI most. And you really should google a bit (developer’s best friend) and check out what code igniter 2.0 will offer to the table before making stupid, ignorant and retarded spamming comments “jheeze”

      • commenter says:

        Enteprise I mean something super large scale and based on extreme high end hardware and server layouts (aka memcache servers, cdn servers, load balancers, etc etc) – to the point where 15mb means nothing (such servers have upto 32gb and i think 64gb of ram), A top 10,000 website globally (based on crappy alexa), making the assumption that all websites aiming to be there offer some sort of complex service to the end user. For such a website the advantages of a fully fledged framework like Symfony or Zend you will see the advantages too. For smaller projects codeigniter or even native code will suffice.

        Obviously Zend on a personal website is way overkill, where as codeigniter fits in perfectly. Each has its use

        The reason I jumped the boat was the way you made a suggestion “use CI”, I know CI2.X is looking miles better than the currtent version, see the above point – every framework is good in places, Codeigniter dont try and say is aimed at such solutions. I hvae used code igniter before for small scale projects but the current version is annoying, I’ve sorted out my own framework which i use instead of it.

        Codeigniter for a one page thing is even overkill, each framework has its place. Codeigniter is introductory, Symfony and Zend are on the other side of the scale.

      • Sk1ppeR says:

        Well i don’t know why you mention memcache and cdn servers in here because i use such techniques everywhere not only on the enterprise websites…and trust me…15mb per user is OVERKILL..EVERYWHERE. The larger the ram is – the longer is the data seek (it is some low miliseconds but there is a latency and there are also limits for data transfer per second it’s not only capacity) And yes i host gaming sites which every user actions are recorded and i have HUGE databases to handle and i try to cache MOST data in the memcache first and all. Of course i have CDN server with nginx for static content…trust me i know what am i talking about :) And as we speak for frameworks … (frameworks not CMS) i think there is no “Each has its use”…it is up to the developer ! This is a “constant” !

  24. park says:

    Well, I don’t thing a lot of these are ZF’s unique feature. It applies to almost all popular MVC frameworks.

  25. cAeSzURA says:

    I have to agree with Kevin, finally a php framework other than codeigniter mentioned.

  26. paulon says:

    very very nice article… :D

  27. PRABHJEET says:

    i have tried to learn zend framework many times. But everytime it sucks. it has long function, classes names to remember, although a good IDE can help you a lot, but i personally dont like it. I like CI much better, just download and you are ready, and you dont have to remember big classes or function names. I would like to use my own OOP framework rather than zend.

  28. tawfekov says:

    ZF is pretty powerful and it would have very nice future
    you can tell from this job trends report from http://www.indeed.com

    http://www.indeed.com/jobtrends?q=zend+framework+,+cakephp+,+codeigniter+,+symfony&l=

    once you used to it , you will love it

    • Peter says:

      Well, I use it … and the more I use it the more I don’t like it!!!

      Too much resources, too much time for developing, tooooo, way too much time for generating a requested page. And also – I didn’t see anything in this framework that is unique and don’t exist in any other!

      So, save your time and be more productive – by avoiding ZF ;)

      :)

  29. I have also tried and made project in zend before 2 years. Now its library size 25+ MB. Its better to use our own framework. Zend can be used for large scale projects not for small scale projects.

  30. fractalbit says:

    The article is very thorough and very well written but i will start with codeIgniter. Seems easier to get started and it helps that nettuts has many screencasts about it :)

  31. Oscar Lagoa says:

    Nice article.
    I am currently using Symfony for a project and ilike it very much but i would like to try ZF.

    I would love to see a ZF tutorial series in Nettuts. ZF documentation sucks. Thats one thing i love in Symfony.
    Theiir tutorials and docs are great. In 2/3 days of following the tutorial at Symfony site you will learn all you need to start coding.

  32. Schleifenzy says:

    Free Premium Coding Tutorials: http://bit.ly/bnTr5I !!!! Join!!! http://bit.ly/bnTr5I

  33. Alejandro says:

    Hey man, don´t forget split, actually it´s deprecated and some CMS and frameworks have problems
    with that.

  34. Patrick says:

    I don’t use any frameworks. They all have functions that are simply useless, inefficient or just bad. Okay, there’s a lot of stuff that’s really cool. But for me, all frameworks use too much RAM, too much CPU and produce bad pagerequest rates.

    I write my own “framework” that fit my needs. Nothing is better. Frameworks are only those, who are too lazy to build his own one.

    • Commenter says:

      Really?
      If your building a fully fledged forum system you’d rather not use a framework and build it on your own “framework”? phpBB4 will be built on Symfony because it saves you reinvtening the wheel.

      There are times when frameworks are right – they make everything easier especially in terms of scalability and expansion. There are other times when frameworks are wrong, or using your own custom framework will suffice.

    • I used to feel the same way, and I had my own framework. If you can make a true framework that is more efficient than CodeIgniter, then you must be a genius. Yes, there are some libraries and helpers that I don’t use, but since they don’t get loaded unless I load them, then I don’t consider that them being there is a problem. I have only used Kohana and CodeIgniter, and CodeIgniter was faster. Maybe you will one day share your framework with the world?

    • Nate says:

      It has nothing to do with laziness.

      If you have the knowledge to build your own framework, then kudos to you. I don’t. I’m not lazy – I want to use something that has a community behind it. A community that tests it, finds and reports bugs, makes suggestions to make it better, and makes it easy enough for me to understand how to efficiently use it with good documentation.

      How do you know when your framework has an exploitable bug?

      • commenter says:

        Closed source applications tend to be less risk for exploits, but people try every exploit in the book when their desperate against your website. Fortunatley the writers do the same thing to ensure its bug free.

        Writing a framework as efficient as codeigniter isnt as hard as it sounds :P – My one works of components, more or less a bunch of them under a base class – with a few of my own + helpers. Some come striaght out of frameworks, mix and match :P – I’ve got Doctrine, Swift Mail, Some sFcomponents – thats all stuff borrowed from the guys that make Symofny. HTML Purify for XSS. Dealing with dates cromes from PHP Datetime class. My own libraries consist of the MVC architecture, the base class and etc etc. All done in a semi-nice oop manner

        Its an old project but kept up to date – Doing this helps not only your PHP skills but with frameworks, especially since half the components come from them.

        Speed doesnt mean much, a fraction of a fraction of a second isnt a difference, bare that in mind

        But I like the point about the community support – another excellent suggestion and works for all developers

    • Patrick says:

      I just mean, that most of the frameworks are too slow, too much functions, too much of all. Okay, i never used symfony – and i never will use. But let me predict: phpbb4 will not be faster then phpbb3. Shake on it!

      i even never said that i’m a genius, BUT i said, what i code it fits my needs. And thats true. i love simplicity. I love performance – without (!) any caching, precompiler and so on. And every “community driven” framework i’ve tested need some extras and modifications to be “really” performant. WordPress is the best example – it’s in fact more a framework then a standalone-blog. And its extremely bad.

      But hey, use what you want ;)

    • Don says:

      How much times it takes to build your own framework?
      Programmer hour fee is expensive.
      Do you think that your framework better then framework that build and tested by a many programmers??
      If you think you are the best please publish your application for community testing and validation – you will get your real grade.

  35. Hieu Vo says:

    I tried Zend, but have already quit because of its complication, and happy with CI now ;)

  36. Jennifer R says:

    Using PHP framework will save a lot of time in developing application but sometimes it’s too big than your needs

  37. Ron says:

    Zend is very powerful, but there are lots of other frameworks around with pro and cons. I think it depends on the project what framework will fit best for the solution.

    –Ron

  38. sarmen says:

    nice article. but i have made my own framework and its 90% oop. i prefer to stay with a framework that ive created myself and know the ins and outs of it. but ill take a look at what classes zend has created to see how i can make my own or if possible use theirs.

    • Author

      You can try using some Zend components and integrating them into your framework – this will make it easier on your part since you don’t have to code something that’s already been coded and tested by a lot of people. You can, for example, use something like Zend_Cache, or Zend_Log. That’s one of the beautiful things about Zend – you don’t really need to use everything, just the ones you need :)

      • Zoran says:

        I agree.
        I am using ZF with CodeIgniter, but only the components i need, plus you can use ZF in any way you want to, it doesn’t have to be MVC or with CodeIgniter. I like Zend_Gdata, Zend_Pdf, Zend_Soap… Talking from perspective of PHP developer i can freely say that Zend Framework is the most professional OOP PHP code out there.
        Btw, thanks for the article.

      • Author

        You should try Zend_Email as well, to handle email sending and reading :)

  39. joddy street says:

    I agree with all the reasons here to use ZF. I am already using it at its fullest. It’s expanding everyday, although its a bit slower and the documentation is complicated but once you set in the steps it’s really great framework. The library is huge and totally customizable. Suggestion take some time to understand it. Would like some awesome tutes on ZF on this awesome site. ZF enthusiasts check : Zendcasts [http://www.zendcasts.com/] [ amazing tutes]
    I just hope ZF introduces ORM too.

    • Author

      For that, you can just use Doctrine. I don’t think they would implement an ORM anytime soon, as they’ve already stopped implementing Zend_Entity, which was supposed to be an ORM implementation. It integrates very well with ZF too :) (I actually use Doctrine + ZF at work).

  40. aditia says:

    hmmm, I’m thinking moving to zend framework too, I think it’s good for bigger website than CI and it has the certification right? hope can added my value, but still not decided yet

  41. Toby says:

    I usually take a more ad hoc ‘el naturale’ approach to most of my projects, reusing only things like my own error checking classes etc. But I’ve had the Zend Framework in mind for my next project, and I think this article just convinced me to make the switch =)

  42. Latavish Gardner says:

    shhhhh….better be quite. There is a discussion about 10 reasons to use the Zend Framework. Bet someone brings up CI. :-)

    Must admit Zend is truly a mighty framework, but the way CI just keeps popping up truly shows how powerful CI is as well. Still sticking with CI.

  43. Michael says:

    Kohana.

    • Steed says:

      Spot on, I’ve used most of the major frameworks and I’ve not found one I like a s much as Kohana.

      Anyone using Codeigniter should really have moved on to this too.

  44. Rok says:

    I love Tuts network and its content… But this article is way below the usual standard. Don’t get me wrong I like Zend but then again I like other frameworks as well and use them on regular basis, but this is the worst Zend propaganda I have ever came across…

    I mean half of this “reasons” have no solid foundation or just make no sense at all… What kind of reason is “It lets you do a Lot of Things!”, so does Codeigniter, Kohana, Cake, etc.

    “Object-oriented Goodness” and “Extend Classes like There’s no Tomorrow”. It makes me wonder if the author actually ever used any of the other frameworks.

    “Community and Documentation”. Actually am baffled by this “reason”…

    So in any case this is poorly written Zend propaganda. Now when we actually come back to earth from this article author could enlighten us with down sides of Zend. This framework is as blown and unnecessarily complicated piece of work. Even for the experienced user, getting your head around ZF is quite a challenge.

    Now I’m not saying this is a bad FW, far from it but I am saying that it shows that ZF was written by the “find solutions to the problems” bunch of people and not “lets avoid problems all together” kind.

    • Author

      The general point of the article is to show how great a candidate Zend Framework can be for your next project — it’s not meant to bash other frameworks or show how Zend Framework is better than the rest (which is to say, not really true).

      I’ve also included a list of downsides to using ZF, if you’ve read the last part of the article. I agree with all your points regarding ZF — it is complicated, it is quite a challenge to learn, but once you get the hang of it, it’ll be really easy to use.

      I don’t understand how this article can be ‘propaganda’ when I’ve not mentioned anything bad against any other framework at all.

      • Rok says:

        Nikko,

        I never meant for this to be as a disrespect towards you, tough it may sounded so. But to me this article came across as such.

        That being said, I believe there are far more solid reasons to use ZF rather than most of the ones you have mentioned, since most of the ones you’ve listed, every other, widely spread FW has as well.

        Again I didn’t mean to show any disrespect, the article is written very well, however the reasons really struck me as non valid or at least not as such that would portray ZF as a wise choice to make.

  45. deerawan says:

    I’ve used Zend for my several projects. Actually, I’m quite satisfied with this framework. I agree with you, Nikko, that for the beginner, it needs really extra time to learn Zend.

    Anyway, I just want Zend can integrate Doctrine or Active Record component so we can still choose which model component that we want to use for our application instead of configure it by ourselves.

    Great Article Nikko :)

  46. Steve Maggs says:

    Thanks for the interesting and thorough write-up!

    I’m on said ‘steep learning curve’ now and as someone still fairly new to php it is a big challenge to use and more importantly to understand to get the most out of it. Thanks to its extensible and comprehensive nature it does have advantages for certain projects that more rigid frameworks don’t.

    Hopefully this article will help me know what I’m doing.

    • Author

      As a beginner, I suggest you study more PHP before you get in too deep with ZF. The reason why I would suggest this is that if you got used to using ZF too much, you’ll wind up not being able to do projects without using Zend (for whatever reason you might not be able to use it). Besides, you’ll understand ZF a LOT easier if you understand PHP as well :)

      I wish you all the luck with learning PHP!

  47. Sachin says:

    I never knew this zend framework can be so useful..thanks for sharing …

  48. Fábio Antunes says:

    Great walk through about Zend.
    When i decided to learn a PHP Framework i have chosen Code Igniter it was easier to learn in that time, and does all you need for small projects.

    When you want simplicity and “little work” to implement i choose CI.
    But when you need a framework who can do everything ZF.

    Any way good work Nikko Bautista.

    • Sk1ppeR says:

      Anything you can do with ZF i can with native code AND codeIgniter…so what’s your point ? Repeat some retard’s comment who sounded like a pro about “ZF is for big “ENTERPRISE” website, code igniter is for small sites” well damn that bullsh*t…as i said i can do everything with code igniter and i bet that i can do it at least twice faster than you and my website will be running at least twice as fast without hip-hoping the PHP without memcache and eAccelerator. I’m so tired of such comments. A good coder doesn’t depend on what base classes his framework offer…hellooo it’s PHP 5 (OOP) you can extend it…without *any* headaches…ffs…stop repeating this crap on any forum you see argument about ZF or cakePHP or CI or any other FW…pick one -> live with it or make your own…i haven’t yet seen a FW website in which it says “Our framework is suitable for coffee shops”, “Our framework is suitable for e-shops”, “Our framework is suitable for w/e” this is a nonsense…big time. As i said earlier…15mb+ footprint per user with no database actions is JUST TOO MUCH FOR ANY KIND OF WEBSITE ! Now i saw the notice about the ZF2 i must admin i haven’t gotten my hands on ZF2 yet but if it have better footprint and it is faster…so why not use it ? I’m a coder who seeks performance…not some hot-shop framework that does nothing compared to others >.>

      • Fábio Antunes says:

        You misjudge me, all PHP projects i do is either with native code or CI. From ZF i mostly use Zend Amf (to directly communicate between PHP and any ActionScript based App, either Flex or AIR).

        CI was the first framework i learned so for me its a special one, and i wouldn’t trade it for any other, but saying that ZF does nothing, thats nonsense.

        However you did reminded that CI as a small footprint, true, about 3mb compared to ZF with 28mb.
        That raises problems with hosting, but most of all with performance.

        ——

        I see why you got so cranky, i shouldn’t have said “for small projects”, your right about that.
        It doesn’t matter what framework you use, they can all do the job with a more or less code, and each one of them as its features.
        The ones that i liked when learning CI was the small footprint, little configuration, great performance, no need to restrict yourself to a specific codding rule and the great documentation that its available.

        ——

        Once you like CI so much i think you would like to know about the coming Code Igniter 2.
        Here Phil Sturgeon gives us a insight about Code Igniter 2.
        http://philsturgeon.co.uk/news/2010/03/codeigniter-2

        Regards Skipper.

  49. Don says:

    when author use windows to work with zend framework and not linux like most of us – its show his programmer level.

    • Rok says:

      I really hope that was a joke… I don’t know what world you are living in but this comment shows you are a geek wannabe programmer…

Comment Page 1 of 21 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.