Written by Anthony Chambers , and read 2,718 times
Always keen on brushing up my PHP skills, I decided to teach myself Zend Framework 2 recently. It's currently still at beta (beta 4, I believe) so there's not a lot of information around to get someone new to ZF off the ground, but I did find this excellent Getting Started with Zend Framework 2 guide on Akrabat.com that I have been working through. Rob Allen, the author, is the author of Zend Framework in Action so knows what he's talking about. I would highly recommend this guide if you're interested in becoming familiar with ZF2.
All that said, I have found issues that are going to cause us problems with implementing a ZF2 application on our servers: It appears that there are aspects of the framework that rely on the is_subclass_of() function, specifically the use of the third (optional) allow_string parameter (which defaults to TRUE, incidentally).
This third and optional parameter was introduced in PHP 5.3.9 and the ZF2 beta 4 that I had calls this function specifying TRUE for this third parameter in (at the very least) the Zend\Form\Factory class. Since our servers are running PHP5.3.3 (you may recall my guide on how to upgrade a CentOS5.7 server to PHP 5.3.3) this throws an exception and I can't progress any further.
Zend\Form\Factory::create expects the $spec["type"] to implement one of Zend\Form\ElementInterface, Zend\Form\FieldsetInterface, or Zend\Form\FormInterface; received Zend\Form\Element
I copied the source from the PHP5.3.3 Linux server to a PHP5.3.9 Windows server to test it and it worked fine. So it's definitely an issue with the PHP versions. I have resolved this today by navigating to the root of the ZF installation and entering:
php composer.phar update
This pulled down the latest version from dev-master and we're up and running again on CentOS5.7 with PHP5.3.3
As a side note, if you're using Rob's guide above, you may find that the database always connects to localhost, whether you want it to or not. The latest version of his article at the time of writing (0.4.3) has a typo in the PDO DSN string on page 14. "hostname" should actually be "host". Make that change and your code should work fine. I've Tweeted Rob to let him know.