I'm developing a new project with Symfony that will have a website and an admin site in the same bundle. I have 2 different connections (one for the data database and one for the admin database) and I wanted to be able to distinguish between entities so for that I have this 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"
Now I'm trying to configure FOSUserBundle and when I want to update the schema for the backoffice database I get the following error: The class 'Project\ProjectBundle\Entity\Backoffice\User' was not found in the chain configured namespaces Project\ProjectBundle\Entity\Project, FOS\U
serBundle\Model
. The FOSUserBundle configuration is:
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%"
Is there any way to achieve that? Another solution that I thought of is having a Bundle with only the project database entities, but I don't know if that would be too complex.
Thanks