通过Guard身份验证在Symfony中使用未知实体名称空间别名 [英] Unknown Entity namespace alias in Symfony by Guard authentication
本文介绍了通过Guard身份验证在Symfony中使用未知实体名称空间别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在与2个独立的实体管理器一起进行Guard身份验证.
I am working on an Guard authentication with 2 separate entity managers.
这是我的配置:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_mysql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
backoffice:
driver: pdo_mysql
host: '%database_backoffice_host%'
port: '%database_backoffice_port%'
dbname: '%database_backoffice_name%'
user: '%database_backoffice_user%'
password: '%database_backoffice_password%'
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
AppBundle: ~
CarBundle: ~
backoffice:
connection: backoffice
mappings:
BackofficeBundle: ~
这是我的安全设置
services:
backoffice.form_login_authenticator:
class: BackofficeBundle\Security\FormLoginAuthenticator
arguments: ["@router", "@security.password_encoder", "@doctrine.orm.backoffice_entity_manager"]
在登录表单之后,找到了用户,并且有一个重定向到我的主路由/backofice,但是我遇到了这个错误:
After the login form, the user is found and there is an redirect to my main route /backofice , but I become this error:
[2017-05-07 18:32:56] request.INFO: Matched route "backoffice_home". {"route":"backoffice_home","route_parameters":{"_controller":"BackofficeBundle\\Controller\\DefaultController::indexAction","_route":"backoffice_home"},"request_uri":"http://ip/backoffice","method":"GET"} []
[2017-05-07 18:32:56] security.DEBUG: Read existing security token from the session. {"key":"_security_main"} []
[2017-05-07 18:32:56] request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\ORMException: "Unknown Entity namespace alias 'BackofficeBundle'." at /home/metahub/autotrader/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php line 271 {"exception":"[object] (Doctrine\\ORM\\ORMException(code: 0): Unknown Entity namespace alias 'BackofficeBundle'. at /home/metahub/autotrader/vendor/doctrine/orm/lib/Doctrine/ORM/ORMException.php:271)"} []
推荐答案
解决方案是这样的:
security:
encoders:
BackofficeBundle\Entity\User: bcrypt
providers:
database_users:
entity:
class: BackofficeBundle:User
property: username
manager_name: backoffice
我们需要直接在安全设置中为此实体设置管理员"manager_name".
We need to setup the manager "manager_name" for this Entity direct in the security settings.
这篇关于通过Guard身份验证在Symfony中使用未知实体名称空间别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文