Zend Framework 1.5 Thoughts

Here at Hawk Host we use Zend Framework for various applications which right now most are not online and will not be any time soon. I cannot even reveal most of the applications because they’re simply not ready to be announced. So I’d say we make heavy use of Zend Framework and I guess the only part which we don’t is our website which currently uses a framework I made, but that may change in the future.

So Zend_Form the Zend solution to generating forms and validation at the same time. I had thought awesome finally no more writing the validation rules and then making HTML and putting it into smarty to finish up the setup. Unfortunately I think I may have overestimated the power of the feature. I had originally thought it also had some inbuilt AJAX functionality which it unfortunately does not. It actually just makes it easier to do some validation on the javascript side it does not actually integrate with something like say JQuery.

But don’t get me wrong here it does have a coolness factor to it even with the lack of real AJAX integration. For example this code below generates a form using a config.ini file opposed to the standard in php setup. This could be great if you want users to control forms while not messing around with the PHP side of things.

PHP File:


$config = new Zend_Config_Ini('/path/to/my/forms.ini', 'development')
$form = new Zend_Form($config->user->login);

Now here’s my forms.ini file

[development]
; general form metainformation
user.login.action = “/user/login”
user.login.method = “post”; username element
user.login.elements.username.type = “text”
user.login.elements.username.options.validators.alnum.validator = “alnum”
user.login.elements.username.options.validators.regex.validator = “regex”
user.login.elements.username.options.validators.regex.options.pattern = “/^[a-z]/i”
user.login.elements.username.options.validators.strlen.validator = “StringLength”
user.login.elements.username.options.validators.strlen.options.min = “6”
user.login.elements.username.options.validators.strlen.options.max = “20”
user.login.elements.username.options.required = true
user.login.elements.username.options.filters.lower.filter = “StringToLower”

; password element
user.login.elements.password.type = “password”
user.login.elements.password.options.validators.strlen.validator = “StringLength”
user.login.elements.password.options.validators.strlen.options.min = “6”
user.login.elements.password.options.required = true

; submit element
user.login.elements.submit.type = “submit”

Pretty cool huh? I imagine I’ll make use of this in some applications, but right now with it being a preview release I have no plans on trying to get any production code up with it. I got it to throw errors a few times while using it and it also did not play nice when I was not using the default Zend_View. Of course this is due to my View system (smarty) not having the required methods to use Zend_Form fine.

There is of course more to it such as Zend_Layout and updates to some other functionality:

  • New Zend_Form component with support for AJAX-enabled form elements
  • New action and view helpers for automating and facilitating AJAX requests and alternate response formats
  • Infocard, OpenID, and LDAP authentication adapters
  • Support for complex Lucene searches, including fuzzy, date-range, and wildcard queries
  • Support for Lucene 2.1 index file format
  • Partial, Placeholder, Action, and Header view helpers for advanced view composition and rendering
  • New Zend_Layout component for automating and facilitating site layouts
  • UTF-8 support for PDF documents
  • New Technorati, SlideShare, and Remember the Milk web services

Right now this is not on the Hawk Host servers as we stick to stable Zend Framework releases. But as always you’re welcome to just upload it to your web space and try it out yourself.

This entry was posted in PHP. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *