<3 __autoload
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.
Fanatic programmer, obsessive technophile, serial entrepreneur and Web 2.0 enthusiast. Zed23.com is the personal blog of Ryan Brooks, a Web Application Developer out of Calgary, Alberta.