Chapter 18. Summary

The more you know, the more you realize you know nothing.

Socrates

WHAT'S IN THIS CHAPTER?

  • Pros and cons of the three frameworks.

  • Table of features.

  • Final comparison.

First of all, we want to say thank you for reading such a thick book and staying with us for so long! We hope you found it helpful and informative.

This is the part many of you have been waiting for: the final comparison of the three frameworks. It goes far beyond listing their unique features; we will mercilessly point out all their advantages and disadvantages here.

FEATURES

We want to start with the big picture: this section presents lists of features for each framework, both good and bad. We've listed only unique traits; if all frameworks perform similarly in an area, that area is not included here. These lists are far from complete and exhaustive, and of course they are affected by our personal experiences, including those we gained while writing this book.

Symfony

Symfony is a great tool for real professionals. It is full-featured and strictly follows all good coding practices.

Advantages

Here is our list of Symfony's advantages:

  • Doctrine object-relational mapping (ORM)–integrated; easy to switch to Propel in a few steps (Chapter 3).

  • Model classes can be generated based on schema or on database tables using command-line interface (CLI) tools. This accelerates the development process (Chapter 4).

  • A lot of plug-ins are available in one place, most of which are well documented, divided into categories. (Used in many chapters; making a plug-in is covered in Chapter 11)

  • Provides interesting plug-ins that introduce additional widgets and validators, extending form-building capabilities (Chapter 5).

  • Form elements encapsulation allows for easy creation of your own widgets and validators (Chapter 5).

  • Provides plug-ins for Sphinx and Lucene search engines (Chapter 7).

  • CLI tools dedicated for testing (Chapter 15).

  • PHPUnit plug-in available for Symfony 1.x; PHPUnit is integrated with Symfony 2.0 (Chapter 15).

  • Symfony 2.0 is integrated with the Twig template engine that introduces its own template language and keeps high performance (Chapter 9).

  • Built-in mechanism that protects against cross-site request forgery (CSRF) attacks (Chapter 8).

  • Forms are filtered by the framework engine (Chapter 8).

  • Some good content management systems (CMSs) are available; many others are available also as plug-ins (Chapter 13).

  • Very good debugging tools (debugging in general — Chapter 15).

  • Version 2.0 upcoming as the first new version among the featured frameworks.

Disadvantages

Here is our list of Symfony's disadvantages:

  • The default testing framework of Symfony 1.x is the Lime framework, which leaves much to be desired (Chapter 15).

  • Some plug-ins are dedicated for old versions of Symfony or are not documented at all, which greatly degrades their quality.

  • Symfony's documentation can be described only as good, while there are many frameworks for which it is excellent.

  • Symfony is great when you finally get to know it. But until you learn how to use it properly, the "500 Internal Server Error" screen (Figure 17-1) will be a common sight for you. Symfony has a great debugger tool with detailed log files, but you have to know how to use it, too. This can be very annoying for beginners.

Symfony's 500 Internal Server Error

Figure 18.1. Symfony's 500 Internal Server Error

CakePHP

CakePHP combines very rapid development and friendliness. It is very intuitive and provides a great tutorial base, which makes using it a real pleasure and allows fast progress even for beginners.

Advantages

The advantages of CakePHP include the following:

  • CakePHP offers its own ORM solution, and it is good enough (Chapter 3).

  • AppModel provides a few basic methods to realize create, read, update, and delete (CRUD) operations, so AppModel is a generic model class. It allows you to very easily create your methods in models or extend inherited ones (Chapter 4).

  • Great integration of models with forms without much coding (Chapter 4).

  • Although there is no official support, there are a few community components and tutorials for Sphinx, Apache, Lucene, and Google Search integration (Chapter 7).

  • SimpleTest testing suite integrated (Chapter 15).

  • Web interface for test execution — an awesome feature (Chapter 15)!

  • CLI tools for test execution (Chapter 15).

  • Delivers the Sanitize class that allows you to filter or clean user input (Chapter 8).

  • Security salt defined in a config file, which helps to secure your application against CSRF attacks (Chapter 8).

  • A lot of tutorials and code snippets in the Bakery — the official CakePHP resource site at http://bakery.cakephp.org/.

  • Some nice CMS solutions — both simple and advanced (Chapter 13).

Disadvantages

The disadvantages of CakePHP include the following:

  • Controller and model are connected very tightly. This is hard to hack when you want a custom behavior. Also, every controller has a $uses field enabled by default, which means it expects to use a model.

  • Does not support Lucene or Sphinx search engines out of the box (Chapter 7).

  • No Selenium test suite support by default (Chapter 15).

  • Debug level for production is set to zero by default — error hiding is not really a good practice.

  • Sticks to PHP4 support for no apparent reason. Hopefully, CakePHP 2.0 will abandon it.

  • Slow performance (Chapter 17).

Zend Framework

Some people argue that ZF is not a framework at all, but a library of useful classes. That makes some sense as ZF is loosely coupled and not really into the ORM thing. It means that it is flexible and easily extensible, but also quite "neutral" (the lists of advantages and disadvantages are both much shorter compared with other frameworks).

Advantages

  • Encapsulates form elements as decorators (Chapter 5).

  • Supports Apache Lucene out of the box (Chapter 7).

  • PHPUnit is integrated with ZF, too (Chapter 15).

  • Provides a few functions and filters to escape user input (Chapter 8).

  • Supports plug-ins through Zend_Plugin (Chapter 11).

  • A few CMSs available, all trying to keep an enterprise impression (Chapter 13).

  • Great high-quality documentation.

  • Good performance speed (Chapter 17).

Disadvantages

  • DbTable is not a real ORM. You have to write three different files full of code to use one model (Chapters 3, 4, and 17).

  • There is no plug-in repository for Zend Framework.

  • It's heavy: 25MB and thousands of files (Chapter 2).

Table of Features

The following table summarizes and compares all the features of the three frameworks that you have observed while reading this book.

 

SYMFONY

CAKEPHP

ZEND FRAMEWORK

SCAFFOLDING

   

Dedicated IDE

Netbeans

None now; will be supported by Netbeans 7

Netbeans, Zend Studio (based on Eclipse)

Code generation

Great CLI tools

A few CLI tools

Poor CLI tools

VIEW

   

Helpers

Core helpers available, easy to use

There are core helpers for most common tasks, easy to use

Core helpers available, easy to use

Template engine

Twig for Symfony2

A bunch of useful helpers only

Zend_view

Additional template engines

Smarty3 available as plug-in

Smarty and Dwoo can be integrated

Smarty and Dwoo can be integrated

COMMUNITY

   

Plug-ins

Lots and all in one place

Some, but scattered

None

Documentation

Good documentation; some official books published

Excellent, well organized, all in one place, lots of examples

Huge, well organized, lots of examples

Video tutorials

Only a few on YouTube

Nice screencasts, a few paid videos, too

A good number of well-done videos

I18N SUPPORT

   

Localization

Helper functions, XML translation files

POT files

Zend_Locale

Internationalization

Doctrine i18n support

CLI tools, schema

Zend_Translate

Database

Supported by Doctrine, available out of the box

Supported, CLI tools available

Not available out of the box; possible to implement

ORM

   

Default ORM

Doctrine

Cake's ORM

Zend's DbTable

ORM support

Very easy to switch to Propel

Possible switch to Doctrine or Propel

Possible switch to Doctrine or Propel

MAILING

   

Default mailer

swiftMailer

Cake Mail component

Zend_Mail

TESTING

   

Testing framework

PHPUnit

SimpleTest + web testing

PHPUnit

Selenium integration support

Through PHPUnit

Add-on needed

Through PHPUnit

SEARCHING

   

Default search engine

Doctrine Search; Lucene and Sphinx as plug-ins

Doesn't support natively

Built-in Apache Lucene support

AND THE WINNER IS...

And the winner is you! Now you know all three frameworks with their features and weaknesses. We hope that you have paid attention to code examples in this book, and perhaps even executed most of them. So you should be familiar with all frameworks and know which one best fulfills your needs.

Well, if you really need our guidance, we can help you make the decision. Just read the following summary and decide which description fits you best. These are partially our personal opinions, so you may not agree with them, of course.

Symfony is a good all-purpose framework. It is very configurable, has great features, and provides tons of plug-ins, mostly useful. With the release of Symfony 2.0, we have a feeling that this framework is generally a half step ahead of the others, but this situation may change soon. If we wanted to point out a decisive winner, we would have said it explicitly.

The bad thing about Symfony is its very steep learning curve. When you finally get to know it, it is great, but many people spend significant time trying to learn it, only to finally switch to another framework, and they are successful at once. There are more intuitive and better-documented frameworks, which in many cases is the decisive factor in rapid web development. We have observed, however, that many people who like Linux operating systems feel good with Symfony and enjoy configuring it to their liking.

CakePHP is also full-featured, but in contrast to Symfony, it is nearly configuration-less and much simpler to use. Simpler is usually faster, and this is the main goal of web frameworks: to speed up the development process! That's why if you are new to PHP frameworks or web development in general, CakePHP may be a much better choice for you. It is also great if you want to make a relatively simple website quickly — baking with Cake is lightning fast!

The convention-over-configuration approach has its price, however. You must know this convention and follow it in your code, which makes the learning curve still rather steep and decreases the framework's flexibility. To make things worse, CakePHP cannot use object-oriented features of PHP 5.0 due to its support for PHP 4.0. This is good when your PHP hosting or PHP skills are five years obsolete and not upgradeable, but in other cases it is a drawback.

Zend Framework generally needs more coding than the previous two solutions to achieve the same effects. On the other hand, Zend Framework doesn't impose its own conventions and it doesn't need much configuration. We have also noticed that many Java programmers like ZF with its library-like approach. It is the preferred solution in these two situations:

  • When you don't need a full framework, but rather a library of components to support your work without taking control over it

  • If you want to buy the full Zend suite

ZF is very popular among corporate users, because with Zend Studio support it is a really great framework and we would love to see it open-sourced (or at least free for use) this way. However, without Zend Studio support ZF lacks several important features, the greatest drawback being its lack of an ORM mapper. Of course, you can install Doctrine quite easily, but it's not supported by the framework itself.