What makes ZF a brilliant framework and what makes it sucks?
The purpose of this post is to give an introduction about Zend Framework. Even if you are not a PHP developer, you may be interested in reading it to know what have been “going on” in the PHP world.
With so many technologies coming up, sometimes is difficult to analyze all of them in order to know which will fit better in your project. The purpose of this post is to show what makes ZF different from other solutions around. So let’s start…
Zend Framework is PHP MVC framework. It’s fully OOP and is actively developed. So far nothing exceptional, right? So let me show you some of the things that make it different.
1. Translation and localization done right!
The ZF developers have taken care of allowing translation of every component in brilliant way. Not everyone speaks English and it sucks to start using a component and find out that you can’t easily translate the error messages, which are in English.
Zend Locale wonderfully does its job by detecting the language and country/region of the user and allowing others components to make use of this information.
- Zend Currency will know the currency symbol of the user’s country.
Eg.: $ 4.00 for Americans and R$ 4,00 for Brazilians.
- If you have a Zend Form field declared as float, it will flawless validate depending if user uses comma or dots as decimal symbols.
Eg.: 1.23 for Americans and 1,23 for Brazilians
- Zend Route will take care to make the urls of your website fully localized, improving SEO.
Eg.: /contact-us/ for Americans and /contacte-nos/ for Brazilians.
- And we can’t forget Zend Date, which will show the date in a way that user understand.
Eg.: 12/31/2010 for Americans and 31/12/2010 for Brazilians.
- There is much more, but i can’t write all night
And no, you don’t have to manually insert this info. It doesn’t matter if your user is from Brazil, USA, Russia or India, their localization info is already in the framework ready to use.
2. High number of well tested and useful components.
Zend Framework offers a vast number of components for different purposes ( checkout their page to see all of them ) They are well tested as the framework development is test driven, so closed bugs are very unlikely to come back.
Whether you are trying to access your twitter account, getting a video info from Youtube or creating a tag cloud for your website, there are components for it saving you a lot of time.
3. Get used to the components and use them, everywhere.
Zend Framework is separated in components and it allows you to use them separately without requiring the full framework structure. There are, of course, some components with dependencies but most of them can be used alone.
Example, you can get the Zend Pdf component and use it in a project with Code Igniter or Cake PHP framework.
So, once you start working more and more with ZF but them have to work on another project, you will be able to use the same components that you are already used for.
4. Let’s bring some coding standards to PHP.
I have to admit, PHP sucks in coding standards. Even on the modules included in language you will find function’s name written in camelCase and functions written with underscore ( no_camel_case ).
It’s not good when you get some code from another developer and he is using camelCase while you are used to use underscores.
Another example are brackets. On an if condition, some developers likes to use in the same line, others in the next line.
The discussion here isn’t which is best, but there must be a standard so that, next time you get a code, you won’t get a bizarre monster made by 5 developers with their own preferences.
ZF clearly dictates some coding standards that you have to follow. All components in the framework use this standard and most of the code that you get is using it too.
5. If there is a standard, use it! Do not create your own!
Another thing that developers have taken care of is to use standards. It’s horrible to get new component that doesn’t follow any standards in its area and tries to create its own. Specially when you already know the standard.
An example:
PHP date’s function consider m as month char and i as minute char. It’s ok, but other’s libraries considers o for month and m for minute.
This is a simple example but when you are dealing with complex stuff, it can make you lose a lot of time.
Zend Date implementation uses ISO 8601 standard. Damn, there is a ISO standard for this, why will you create your own?
Ok, but what make it sucks?
I have written only a few aspects that make ZF rocks. So I will save some of them for a next post. Let’s talk about what make it sucks.
The main thing that still sucks in Zend Framework is the documentation. Although all components are documented there are too few examples and some of them do not work correctly, requiring some changes to achieve their purpose.
This is bad specially when you are learning something new. I often have to dig in the code of a component to find how a feature works. Sometimes because the example in manual is wrong and sometimes because the manual simply ignore the feature that i am trying to use.
Fortunately the developers are aware of this and one of the things which will be worked in version 2.0 is a better manual specially for people that are starting with the framework. Let’s hope that they can improve this
Conclusion
I have been working with Zend Framework for approximately 2 years and it has been a fun and productive experience.I am doing things much faster ( and IMO, cleaner ) than with any other framework that i worked before, like CodeIgniter or Symfony.
Unfortunately i cannot work with it full time because of other projects, but whenever a new project shows up, ZF is always my first choice as i know that it will save a lot of time.
Learning a new framework is a hard task. At the beginning you have to “learn again” lots of things and sometimes change your way of solving some kind of problems. With ZF is not different, but i would really recommend that you give it a try. I haven’t regretted at all!


6 February, 2012 at 4:34
Just started on with Zend recently. Thanks for this interesting read.