我正在与Symfony开发一个新项目,该项目将在同一个包中拥有一个网站和一个管理站点。我有2个不同的连接(一个用于数据数据库,一个用于管理数据库),我希望能够区分实体,因此我有config.yml
:
doctrine:
dbal:
default_connection: project
connections:
project:
driver: pdo_pgsql
host: '%database_host%'
port: '%database_port%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: UTF8
backoffice:
driver: pdo_pgsql
host: '%backoffice_database_host%'
port: '%backoffice_database_port%'
dbname: '%backoffice_database_name%'
user: '%backoffice_database_user%'
password: '%backoffice_database_password%'
charset: UTF8
orm:
default_entity_manager: project
entity_managers:
project:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: project
auto_mapping: true
mappings:
# you must specify the type
type: "annotation"
# The directory for entity (relative to bundle path)
dir: "Entity/project"
#the prefix
prefix: "Project\\ProjectBundle\\Entity\\Project"
backoffice:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: backoffice
mappings:
# you must specify the type
type: "annotation"
# The directory for entity (relative to bundle path)
dir: "Entity/Backoffice/"
#the prefix
prefix: "Project\\ProjectBundle\\Entity\\Backoffice"
现在我正在尝试配置FOSUserBundle,当我想更新后台数据库的架构时,我收到以下错误:The class 'Project\ProjectBundle\Entity\Backoffice\User' was not found in the chain configured namespaces Project\ProjectBundle\Entity\Project, FOS\U
serBundle\Model
。 FOSUserBundle配置为:
fos_user:
db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel'
firewall_name: backoffice
user_class: Project\ProjectBundle\Entity\Backoffice\User
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
有没有办法实现这一目标?我想到的另一个解决方案是使用仅包含项目数据库实体的Bundle,但我不知道这是否太复杂。
由于