ZF-7764: Allow easy configuration of classResources


I have created a patch that allows to configure classResources same as plugins.

Options can be set via the resources configuration, where classResource also can be disabled. Like:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    protected function _initCache()
        $file = $this->getOption('defaultcachedir'). 'pluginLoaderCache.php';
        if (file_exists($file)) {
            include_once $file;
        if ($this->getOption('plugin')) {

    protected function _initSession() {
        $session = new Zend_Session_Namespace( $this->getOption('name') );
        Zend_Registry::set( 'session', $session );
        if (!isset($session->initialized)) {
            $session->initialized = true;

With this config:

<?xml version="1.0"?>

Where _initCache will not be called.


I like it :D

Only thing i dont get: Cache and Session are available Resource Plugins, why not only use this?

But the Disable feature is nice, would like to see this for Res-Plug-Ins too.

Well cache isn't available AFAIK and the session resource doesn't do what this does. BUT, this is only an example about how it would work. Resourceplugins you can disable already by just removing them from the resource config.

updated it

I would personally like to see some benchmarks about this. Though the feature is nice, it's not essential imho, and it has the potential of slowing down every app based on zend_app.

I did 2 runs of 10k, results are the patch hardly makes a difference (only a bit faster). See the attached results and files i ran the test with.

Notice that there is no checking if the options actually exists (so results in a notice error) in the 'old' implementation. An extra check would only make it slower.

Also, since you are saving the config into a local variable, more calls to the getOptions or a bigger config file will make it slower.