Zend Bootstrap “Circular resource dependency detected” error

So you have also got it :)? This is one of the more strange errors in the Zend Framework if you ask me. One way to get it is to give the init function the “wrong” name in the bootstrap class:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
    
    protected function _initAutoload() {
        $loader = new Zend_Application_Module_Autoloader(array(
        'namespace' => 'Application',
        'basePath' => APPLICATION_PATH
        ));

        return $loader;
    }

    protected function _initDbAdapter() {
        $this->bootstrap('db');
        $db = $this->getResource('db');
        Zend_Registry::set('db' , $db);
    }

    protected function _initConfig() {
        Zend_Registry::set('config', $this->getOptions());
    }  
    
    protected function _initTranslate() {

        $this->bootstrap("translate");
        $translator = $this->getResource("translate");
        Zend_Registry::set('translator', $translator);
    }
 
}

You see something wrong here? I didn’t 🙂 But there is a problem with ‘initTranslate()’ function. The last part of the name is ‘Translate’ which is the same as the

$this->bootstrap("translate"); 

call. If the bootstrap call is ‘translate’ you can not name the init function ‘Translate’ (case does not matter) so you have to do this:

protected function _initTranslator() { // not '_initTranslate'

        $this->bootstrap("translate");
        $translator = $this->getResource("translate");
        Zend_Registry::set('translator', $translator);
    }

Now the name of the function and the bootstrap call are different from each other which should make the error go away

Hope this saves someone some time. Tested in Zend Framework 1.10

  1. Hi Niklas. You saved the day (mine at least). Thanks a lot for the post. 😀

  2. Thanks a lot 🙂

  3. Someone should buy you a beer today. Thanks!

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">

This site uses Akismet to reduce spam. Learn how your comment data is processed.