<3 __autoload

Posted February 21, 2007, 9:03am In: Zend Framework, PHP

When developing with the Zend Framework, it’s been my experience that the majority of our class files have a myriad of require statements before the class declaration. There are cases where these requires are not needed.

PHP 5.2.1 brings us all sorts of new goodies, one of them being the method spl_autoload_register(), part of the Standard PHP Library. When we tie this in with Zend::loadClass(), we can load our class files as needed.

Though there is some question about problems with application servers and things like bytecode caching, this gives us the added benefit of enforcing consistency in class naming - with consistency comes predictability, and saves us from having to RTFM, or double check our directory structure every time to find the proper file.

Though I am using this autoload method, I want to make sure that it is not slowing my applications down - there is quite some heated discussion on using auto-magical methods versus carefully crafted include statements. I’ll be paying very close attention to my dispatch times, and time will tell if I continue using this method.

This entry was posted on Wednesday, February 21st, 2007 at 9:03 am and is filed under Zend Framework, PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No Responses...

Leave a reply...

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>