我正在通过开始编写一个简单的 UserAuth 插件来进行身份验证来学习 ZF2,但是遇到了异常:创建“userAuth”时引发了异常;没有返回实例以前的异常:提供的或实例化的驱动程序对象没有实现 Zend\Db\Adapter\Driver\DriverInterface
这一行的错误: $sm->get('Zend\Db\Adapter\Adapter')
以下是我的 User\Module.php
类模块{
public function onBootstrap(MvcEvent $e)
{
$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfig()
{
return array(
'invokables' => array(
),
'factories' => array(
'User\Form\Signin' => function($sm) {
$form = new Form\Signin();
$form->setInputFilter(new Form\SigninFilter);
return $form;
},
'User\Auth\Service' => function ($sm) {
return new \Zend\Authentication\AuthenticationService(
new \Zend\Authentication\Storage\Session(),
new \Zend\Authentication\Adapter\DbTable($sm->get('Zend\Db\Adapter\Adapter'))
);
},
),
);
}
public function getControllerPluginConfig()
{
return array(
'factories' => array(
'UserAuth' => function ($sm) {
$sl = $sm->getServiceLocator();
$authService = $sl->get('User\Auth\Service');
$authAdapter = new \Zend\Authentication\Adapter\DbTable($sm->get('Zend\Db\Adapter\Adapter'));
$controllerPlugin = new Controller\Plugin\UserAuth();
$controllerPlugin->setAuthService($authService);
$controllerPlugin->setAuthAdapter($authAdapter);
return $controllerPlugin;
},
),
);
}
}
请帮我修复它。