0
votes

Here is my complete error:

Strict Standards: Accessing static property Bootstrap::$frontController as non static in /Users/panda/Dropbox/www/_playground/myApp/Zend/Application/Resource/Frontcontroller.php on line 145

Fatal error: Uncaught exception 'Zend_Exception' with message 'Registry is already initialized' in /Users/panda/Dropbox/www/_playground/myApp/Zend/Registry.php:70 Stack trace: #0 /Users/panda/Dropbox/www/_playground/myApp/application/Bootstrap.php(217): Zend_Registry::setInstance(Object(Zend_Registry)) #1 /Users/panda/Dropbox/www/_playground/myApp/application/Bootstrap.php(56): Bootstrap->_initSetupRegistry() #2 /Users/panda/Dropbox/www/_playground/myApp/Zend/Application/Bootstrap/BootstrapAbstract.php(669): Bootstrap->_initPrepare() #3 /Users/panda/Dropbox/www/_playground/myApp/Zend/Application/Bootstrap/BootstrapAbstract.php(622): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('prepare') 4 /Users/panda/Dropbox/www/_playground/myApp/Zend/Application/Bootstrap/BootstrapAbstract.php(586): Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #5 /Users/panda/Dropbox/www/_playground/myApp/Zend/Application.php(355): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap(NULL) #6 in /Users/panda/Dropbox/www/_playground/myApp/Zend/Registry.php on line 70

Here is the function from my bootstrap

/*
* Zend_Registry get's born here so it can be accesed
*/
protected function _initSetupRegistry()
{

    self::$registry = new Zend_Registry(array(), ArrayObject::ARRAY_AS_PROPS);
    Zend_Registry::setInstance(self::$registry);

}

If you need more code, please let me know, I will like some tips for finding the problem, or if someone knows the exact problem.

Thank you!

1

1 Answers

2
votes

What are you trying to achieve with this method?

If you just want an instance of the registry use Zend_Registry::getInstance(). You shouldn't be constructing it (I'm not sure why they used a singleton pattern but didn't make __construct private).

If you really want to replace an instance of Zend_Registry call Zend_Registry::_unsetInstance() first.

If you just want to set the static $registry variable so you can reference it later try:

self::$registry = Zend_Registry::getInstance(); 
self::$registry->set('configuration', 'myconfig');

But I'm not sure this is necessary because you can access Zend_Registry::getInstance() from any scope. So the above is the same as:

Zend_Registry::getInstance()->set('configuration', 'myconfig');

Which you can call anywhere.