doxp30826 2013-01-16 18:44 采纳率: 0%
浏览 39
已采纳

'Zend_Exception' - >'注册表已初始化'

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条回答 默认 最新

  • douqingnao9246 2013-01-16 18:48
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据