没有实例返回Zend Framework 2?

时间:2013-12-04 05:17:18

标签: zend-framework2 instance adapter cpanel

我已经开发了一个项目,并成功地在我的本地机器上工作。在实时网站我在public_html中创建一个文件夹dev并从本地机器移动相同的项目,但它给了我以下错误。

  

的Zend \的ServiceManager \异常\ ServiceNotCreatedException

File: /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:859
Message: An exception was raised while creating "Front/Model/Slider"; no instance returned
  

Zend \ ServiceManager \ Exception \ ServiceNotCreatedException

File: /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:859
Message: An exception was raised while creating "Zend\Db\Adapter\Adapter"; no instance returned
  

的Zend \ DB \适配器\异常\ RuntimeException的

File: /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Pdo.php:218
Message: The PDO extension is required for this adapter but the extension is not loaded..

我的服务工厂意味着model.config.php文件是:

<?php
    namespace Front;
    /*use Zend\ModuleManager\ModuleManager;*/
    class Module
    {
        public function getAutoloaderConfig()
        {
            return array('Zend\Loader\StandardAutoloader' =>
                array('namespaces' =>
                    array(__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,),
                ),
            );
        }
    /*    public function init(ModuleManager $moduleManager)
        {
            $sharedEvents = $moduleManager->getEventManager()->getSharedManager();
            $sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
                // This event will only be fired when an ActionController under the MyModule namespace is dispatched.
                $controller = $e->getTarget();
                $controller->layout('layout/frontlayout');
            }, 100);
        }
    */
        public function getConfig()
        {
            return include __DIR__ . '/config/module.config.php';
        }
        // Add this method:
        public function getServiceConfig()
        {
            return array(
                'factories' => array(

                    'Front\Model\Cms' =>  function($sm) {
                        $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                        $table     = new \Front\Model\Cms($dbAdapter);
                        return $table;
                    },

                    'Front\Model\Slider' => function($sm) {
                        $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                        $table     = new \Front\Model\Slider($dbAdapter);
                        return $table;
                    },

                ),
            );
        }
    }
    ?>

Stack Trace是这样的:

  

的Zend \的ServiceManager \异常\ ServiceNotCreatedException

File: /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:859
Message: An exception was raised while creating "Front/Model/Slider"; no instance returned

#0 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(984): Zend\ServiceManager\ServiceManager->createServiceViaCallback(Object(Closure), 'frontmodelslide...', 'Front/Model/Sli...')
#1 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(597): Zend\ServiceManager\ServiceManager->createFromFactory('frontmodelslide...', 'Front/Model/Sli...')
#2 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(556): Zend\ServiceManager\ServiceManager->doCreate('Front/Model/Sli...', 'frontmodelslide...')
#3 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php(480): Zend\ServiceManager\ServiceManager->create(Array)
#4 /home/projectname/public_html/dev/module/Front/src/Front/Controller/FrontController.php(65): Zend\ServiceManager\ServiceManager->get('Front/Model/Sli...')
#5 /home/projectname/public_html/dev/module/Front/src/Front/Controller/FrontController.php(53): Front\Controller\FrontController->getSlider()
#6 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractActionController.php(83): Front\Controller\FrontController->indexAction()
#7 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))
#8 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#9 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/Mvc/Controller/AbstractController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/Mvc/DispatchListener.php(114): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#12 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#13 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#14 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#15 /home/projectname/public_html/dev/vendor/zendframework/zendframework/library/Zend/Mvc/Application.php(309): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 /home/projectname/public_html/dev/public/index.php(17): Zend\Mvc\Application->run()
#17 {main}

1 个答案:

答案 0 :(得分:2)

  

此适配器需要PDO扩展名,但未加载扩展名

这给你答案:php有一个名为php data objects或pdo的模块。这是现代php安装中可用的模块,可以为您的php应用程序启用数据库访问。

我认为有三个可能的原因:

  1. 您没有安装pdo模块
  2. 您已安装pdo作为模块但未启用
  3. 你有一个旧版本的PHP。对于Zend Framework 2,最低限度需要php 5.3.3
  4. 因此,您可能需要升级或配置服务器才能实现此功能。