Zend_Loader humm…
So far its a nice sunday afternoon. Im spending the day at my mom/dad house and just reading over the zend framework’s php code.
I’ve stumbled across a few items of interest but this one is a bit of a interesting knugget.
In line 80 in the Cache.php file this is pointed out ” // For perfs reasons, we do not use the Zend_Loader::loadClass() method”
Im looking at the 1.5.1 code base so its the latest code. The only reason i point this out, well to myself at least, is that in the
documentation it points out that there is no added benefit in using Zend_Loader a pose to require_once/require calls.
Why wouldnt Zend state this in their documentation? Given the current language in the documentation it seems like Zend_Load and
require will have the same benefit and performance drawbacks which isnt the case looking at the code.
Either way. Keep up the great work Zend. I love you guys lol
Armando Padilla
The author of Zend_Cache is a big performance zealot, so I’m not surprised to read of that comment.
One of our engineers did some benchmarking of Zend_Loader coming into the 1.0.4 and 1.5.0 releases to determine how it stacks up to require_once calls. The results were interesting — Zend_Loader is typically only a few percentage points slower than using require_once.
Currently, within the ZF codebase, we encourage using require_once over Zend_Loader *unless* the class name is being calculated dynamically — such as with plugins and helpers. This helps with class detection in IDEs as well as with API documentation generation. For applications built on top of ZF, we encourage using autoloading, via Zend_Loader::registerAutoload(). This makes development easier for the developer as they do not need to track their dependencies, and makes the code more readable.
Looking forward to 2.0, we will likely move to all autoloading. With the improvements in the 5.2.x PHP series regarding the realpath cache, the differences in performance between autoloading and using require_once are nominal, and the benefits to development of using autoloading are tremendous.