我正在使用zf2和zfcuser模塊與教義的項目。我創建了一個自定義用戶模塊,它擴展了zfcuser,也是用戶表的一個自定義實體,並對集成進行了所有必要的更改。但我的問題是,試圖對自己進行身份驗證時,我得到這個錯誤:zfcuser + doctrine自定義用戶實體
An alias "Zend\Db\Adapter\Adapter" was requested but no service could be found.
這種情況zfcuser_user_mapper試圖更改適配器時。
注:我不是很清楚爲什麼我需要使用Zend \ Db \ Adapter \ Adapter,因爲我正在使用教義。
這是自定義用戶模塊的module.php中的代碼。
public function getServiceConfig() {
return [
'aliases' => array(
'zfcuser_zend_db_adapter' => 'Zend\Db\Adapter\Adapter',
),
'factories' => [
'usuario_login_form' => 'Usuario\Factory\Form\Login',
'usuario_registro_form' => 'Usuario\Factory\Form\Register',
'usuario_user_service' => 'Usuario\Factory\Service\UserFactory',
//'usuario_user_mapper' => 'Usuario\Factory\Mapper\User',
'usuario_auth_service' => 'Usuario\Factory\AuthenticationService',
'Usuario\Authentication\Adapter\Db' => 'Usuario\Factory\Authentication\Adapter\DbFactory',
'Usuario\Authentication\Storage\Db' => 'Usuario\Factory\Authentication\Storage\DbFactory',
//'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\Adapter',
'usuario_user_mapper' => function ($sm) {
$mapper = new Mapper\User();
$mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter'));
$mapper->setEntityPrototype(new ORM\Entity\Usuarios());
$mapper->setHydrator(new \ZfcUser\Mapper\UserHydrator());
return $mapper;
},
]
];
}
這是我global.php文件
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => 'toor',
'dbname' => 'deporte',
)
)
)
),
);
這是我module.config.php文件:
'controllers' => array(
),
'doctrine' => array(
'driver' => array(
// overriding zfc-user-doctrine-orm's config
'usuario_entity' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'paths' => __DIR__ . '/../src/Usuario/ORM/Entity',
),
'orm_default' => array(
'drivers' => array(
'Usuario\ORM\Entity' => 'usuario_entity',
),
),
),
),
'zfcuser' => array(
'auth_adapters' => array(100 => 'Usuario\Authentication\Adapter\Db'),
// telling ZfcUser to use our own class
'user_entity_class' => 'Usuario\ORM\Entity\Usuarios',
// telling ZfcUserDoctrineORM to skip the entities it defines
'enable_default_entities' => false,
),
感謝您對我的幫助,我已經被這個錯誤了好幾天。非常感謝你,請原諒我的英語。
你安裝zfcuser-ORM-學說?而且,您是否嘗試刪除別名,「zfcuser_zend_db_adapter」=>'Zend \ Db \ Adapter \ Adapter','? –