未捕获的异常'Zend_Application_Bootstrap_Exception',消息'资源匹配'multidb“未找到”

时间:2015-02-02 10:08:34

标签: php zend-framework

为什么" ' Zend_Application_Bootstrap_Exception'与消息'资源匹配" multidb"找不到'在/home/eat/public_html/library/Zend/Application/Bootstrap/BootstrapAbstract.php:691"出现?

当我有$this->bootstrap('multidb')而不是getResource('multidb')

下面是我的boostrap.php代码,

<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    public function __construct($application)
    {
        parent::__construct($application);
    }

    protected function _initAutoload()
    {

        Zend_Controller_Action_HelperBroker::addPrefix('Eat_Controller_Action_Helper');

    $autoloader = new Zend_Application_Module_Autoloader(
            array(
              'namespace' => '',
              'basePath' => APPLICATION_PATH,
              'resourceTypes' => array(
                'form' => array(
                  'path' => 'forms',
                  'namespace' => 'Form',
                ),
                'model' => array(
                  'path' => 'models',
                  'namespace' => 'Model',
                ),
              )
            )
    );

    return $autoloader;
  }



  protected function _initLayoutHelper()
  {
    $this->bootstrap('frontController');

    $layout = Zend_Controller_Action_HelperBroker::addHelper(new Eat_Controller_Action_Helper_LayoutLoader());

  }

  protected function _initApplication()
  {

    $config = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV);
    Zend_Registry::set("config", $config);


    $locale = new Zend_Locale();
    Zend_Registry::set('Zend_Locale', $locale);

    //init DB connection
    try {

        $this->bootstrap('multidb');
        $multiDb = $this->getPluginResource('multidb');

        $db = $multiDb->getDb('default');
        $db->setFetchMode(Zend_Db::FETCH_OBJ);
        $db->getConnection();
        $db->getProfiler()->setEnabled(true);

        Zend_Registry::set('db', $db);

         //Just making everything UTF8. This is a hack, need to find the proper Zend way
        $db     = Zend_Registry::get('db');
        $db->query('SET NAMES "utf8"')->execute();


    } catch (Zend_Db_Adapter_Exception $e) {

        die("Error connecting to database: " . $e->getMessage());

    }


  }

  public function _initRoutes()
  {
    /*
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routes.ini', APPLICATION_ENV);
    $router->addConfig($config, 'resources');


    $routes['featured'] = new Zend_Controller_Router_Route(
            'featured/:id',
            array('controller' => 'index', 'action' => 'featured', 'id' => null)
    );

    Zend_Controller_Front::getInstance()->getRouter()->addRoutes($routes);
    */
  }


    protected function _initLanguages()
    {


    }


    //Initilaize zend ACL
    public function _initAcl()
    {
        //Omit the process in CLI mode
        if (php_sapi_name() != 'cli')
        {
            $helper = new Eat_Controller_Action_Helper_AclDefault();
            $helper->setRoles();
            $helper->setResources();
            $helper->setPrivilages();
            $helper->setAcl();

            //Register the ACL plugin - Then it will be called automatically,whenever an acion is called
            $this->bootstrap('frontController');
            $frontController = Zend_Controller_Front::getInstance();
       // $frontController->registerPlugin(new Eat_Plugin_Acl());


        }
    }

    //Initialize error controller
    public function _initErrorSwitcher()
    {
        $this->bootstrap('frontController');
        $frontController = Zend_Controller_Front::getInstance();
        $frontController->registerPlugin(new Eat_Plugin_ErrorControllerSwitcher());
    }

    protected function _initZFDebug()
    {
        //  Enabling this method seems to break autocomplete. Use only when needed
        $autoloader = Zend_Loader_Autoloader::getInstance ();
        $autoloader->registerNamespace ( 'ZFDebug' );

        $db = Zend_Registry::get ( 'db' );

        $cache = Zend_Cache::factory ( 'Core', 'File' );

        //Zend_Controller_Front::getInstance()->getBaseUrl();
        //APPLICATION_PATH
        $options = array ('plugins' => array ('Variables', 'Database' => array ('adapter' => $db ), 'File' => array ('basePath' => Zend_Controller_Front::getInstance ()->getBaseUrl () ), 'Memory', 'Time', 'Registry', 'Cache' => array ('backend' => $cache->getBackend () ), 'Exception' ) );

        $debug = new ZFDebug_Controller_Plugin_Debug ( $options );

        $this->bootstrap ( 'frontController' );
        $frontController = $this->getResource ( 'frontController' );
        //$frontController->registerPlugin ( $debug );


    }






}

的application.ini

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

eat.application.base.url = "eat.com"
eat.application.admin.url = "admin.eat.com"
eat.application.api.url = "api.eat.com"

includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.prefixDefaultModule = "1"

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

autoloaderNamespaces[] = "Eat_"

resources.modules = ""

phpSettings.date.timezone = "GMT"

eat.application.salt = "sd876fs89df";
resources.view[] =
resources.view.helperPath.Eat_View_Helper = APPLICATION_PATH "/../library/Eat/View/Helper"

;;; Databases


;;;;; Layouts

resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"
resources.layout.layout = web/web

nexva.applicaiton.fileUploadDirectory = APPLICATION_PATH "/../files"

;;;; ReCaptcha ;;;;
recaptcha.private_key = 6LfL7rsSAAAAAKgtKWsMk4hmA2DSVq0ODcyJFRjs
recaptcha.public_key = 6LfL7rsSAAAAANiaZOQN7LOoCGAXh29rHTZPRoVa

[staging : production]
eat.application.base.url = "eat.com"
eat.application.admin.url = "admin.eat.com"
eat.application.api.url = "api.eat.com"

;;; Databases
resources.multidb.default.adapter       = mysqli
resources.multidb.default.host          = "localhost"
resources.multidb.default.username      = "eat"
resources.multidb.default.password      = "eat"
resources.multidb.default.dbname        = "eat_main"
resources.multidb.default.default       = true

1 个答案:

答案 0 :(得分:1)

在application.ini中,您尚未在生产环境中声明multidb选项。帽子是Zend无法找到插件的原因。

你必须添加它们

[production]
resources.multidb.default.adapter       = mysqli
resources.multidb.default.host          = "localhost"
resources.multidb.default.username      = "eat"
resources.multidb.default.password      = "eat"
resources.multidb.default.dbname        = "eat_main"
resources.multidb.default.default       = true