Day number two of porting this application to zend framework 2. I only had a couple of hours today but still i have a couple of things i actually want to talk about. I keep encountering things that are not that much different from ZF1 like Zend\Navigation or Zend\Paginator. I was quite surprised i got them working in seconds.
In the app i have a paginated list of documents, and below is how the code changed:
Zend Framework 1
$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$select = $db->select()->from('document', $orders)->order(array("$order $way"));
$paginator = Zend_Paginator::factory($select);
Zend Framework 2
$db = $this->getServiceLocator()->get('db');
$select = new Select('document');
$paginator = new Paginator(new DbSelect($select, $db));
Which if you exclude all the Use Statements you have to add on top it's not bad, i actually think it pretty much the same. It would be nice to be able to get the Select object from the adapter but it's not a big deal. The second thing of the day was how actively the ZF2 is developed. I found a couple bugs today working with v2.0.3. The most important was with the Zend\Mvc\Router\Http\Query which was adding the controller, action and namespace parameters to the query string, instead of only adding the extra parameters it was receiving. But guess what download the latest version from github and voila bugs are gone. (Lithium are you there... ;p). That really made my day, i make it a habit not following popular trends or rooting for the underdogs, see my history. I started learning php with LDU cms probably the most unkown cms of all and now choosing Lithium for Komposta Core instead of one of the most popular frameworks like Zend or Symphone or CakePHP for pete sake. So it felt great to go from the disappointing moment of finding a bug to see that i was fixed in a minute. People are whining how much ZF2 changed and that it got a bit Java-ish but today at least, in my mind ZF2 will succeed because of the active developers and contributors.
The idea of building a cmf came to me 2 years ago, at the time i wasn't into php frameworks, i intended to build it from scratch and i came very close to a release candidate a year ago but my pet project had to be put on hold. I started work at Greek Ministry of Education and i was involved on a lot of web projects and to speed up the procedure i choose Zend Framework as the industry standard choice. That's when i fall in love with php frameworks. Zend 1.11.x was easy to work with, it didn't bound the programmer to follow a strict path and had (probably still has) a huge variety of libraries to accommodate any programmers need. Another big factor on choosing Zend was the excellent documentation and on-line sources.
Six weeks ago when i decided to restart my pet project i had to choose between continuing with my php framework or go Zend. Unfortunately my php framework had to die young because i wanted to have something ready for production this year. Zend framework 2.0 was well under the way but at the time only beta versions had surfaced. I have to admit that after peaking at the source code of ZF2 i wasn't impressed but i won't comment on it until i have the time to check the stable version that was released last week.
After that i was on a php framework hunt and limited the options pool to Symphony2, Kohana and Lithium. I quickly eliminated Symphony because it looked like it has a very steep learning curve. Kohana, although i promise to keep in touch, is lacking in cutting edge PHP features. After quick tests i was impressed with Lithium. It's relatively small and fast, it doesn't impose stupid restrictions to the programmers and has a better than good in-house Data Model solution. Of course it has some grey areas but because it's so flexible you can bypass any problem or bug easily.
But i have to admit the number one reason for my choice was the news about Lithium getting sponsored by Engine Yards. Honestly Lithium development has slowed down a lot this year and until the news from Engine Yards i wasn't sure if Lithium was dead or alive. Documentation is sketchy at best, online sources are limited and git support is, well hrm... If you are new to php go with a framework with good documentation and community like CakePHP, otherwise be prepared for a lot of code reading or stay tuned, lithium tutorials are on the way...