Good to hear this is moving forward. I've been doing some tests of my own over the last 24 hours on the 1.5.3 release. I've run into a few issues, but nothing that cant be resolved.

For the benefit of anyone who's interested, this is what I've been doing:

My aim was to allow the use of any class loader (taking advantage of spl_autoload), and to ensure that all classes load through it (wherever possible). As a loader may or may not use the include_path (mine doesn't), it shouldn't be a requirement to have the ZF library path in the include_path, this meant that any call to require_once "Zend/..." needed to be removed.

Then there's the issue of direct calls to Zend_Loader::loadClass(), which appear throughout various ZF components. Luckily none of the calls make use of the 2nd argument of loadClass(), the $paths list, so it was a simple task of replacing all Zend_Loader::loadClass() calls with spl_autoload_call(). I'm fairly sure that these could actually have been removed completely rather than replaced, as the autoloader should take care of it, but I didn't do that yet, just in case.

These simple replacements only left me with three problem require_once statements, which were in Zend/Cache.php and Zend/Memory.php and all looked something like this:

require_once str_replace('_', DIRECTORY_SEPARATOR, $frontendClass) . '.php';

Replacing these with:

spl_autoload_call($frontendClass);

Solved that one.

Now, as far as it know, this covers all the main class loading in ZF. I don't think that the loading of controller/view helpers/filters/plugins should be delegated to the autoloader, because in many cases, the relevant paths don't map directly to the class name (ie. view helpers in ".../views/helpers"), and you probably wouldn't want all the different paths to helpers etc. in your general class loader. The PluginLoader already does a good job of loading these.

However, there is one more problem. As I mentioned before, I didn't want it to be a requirement to have the ZF library path in the include_path, however at present Zend_Controller_Action_HelperBroker relies upon it. The helper broker currently has an addPrefix() method, which allows you to add just a class name prefix, and no related path, but by doing that, the broker cannot create an absolute path to the class files. This is easily solved when adding your own paths by using addPath() instead, however the broker adds "Zend_Controller_Action_Helper_" in by default. There's no easy way round this at present, other than adding this into the brokers __construct method:

self::$_paths = array(array(
   'dir'    => dirname(__FILE__) . '/Helper/',
   'prefix' => 'Zend_Controller_Action_Helper_'
));

So, that's as far as I've got. All in all, the removal of the require_once and loadClass calls gave me around a 15-20% speed improvement, and more importantly, the ability to use my own class loader makes it all the more flexible.
--
Jack

Reply via email to