I'm working on rewriting an old plain PHP bad written app with Symfony 4.4 and Doctrine 2.12. Due to the number of databases (5) and the XXL size of them (at least 50 tables per database with often more than 100 columns) I had to generate entities from reverse engineering. Here is my Doctrine configuration.
doctrine:
dbal:
connections:
fire:
url: '%env(resolve:FIRE_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair:
url: '%env(resolve:LECLAIR_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair_vad:
url: '%env(resolve:LECLAIR_VAD_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair_int:
url: '%env(resolve:LECLAIR_INT_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
leclair_mobi:
url: '%env(resolve:LECLAIR_MOBI_DATABASE_URL)%'
driver: 'pdo_mysql'
server_version: 'mariadb-10.6.5'
charset: 'utf8mb4'
default_table_options:
charset: 'utf8mb4'
collate: 'utf8mb4_general_ci'
schema_filter: ~.*[^_to_del]$~
options:
1001: true
orm:
default_entity_manager: leclair
auto_generate_proxy_classes: true
entity_managers:
fire:
connection: fire
mappings:
Fire:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Fire'
prefix: 'App\Entity\Fire'
alias: Fire
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair:
connection: leclair
mappings:
Leclair:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/Leclair'
prefix: 'App\Entity\Leclair'
alias: Leclair
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair_vad:
connection: leclair_vad
mappings:
LeclairVad:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/LeclairVad'
prefix: 'App\Entity\LeclairVad'
alias: LeclairVad
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair_int:
connection: leclair_int
mappings:
LeclairInt:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/LeclairInt'
prefix: 'App\Entity\LeclairInt'
alias: LeclairInt
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
leclair_mobi:
connection: leclair_mobi
mappings:
LeclairMobi:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity/LeclairMobi'
prefix: 'App\Entity\LeclairMobi'
alias: LeclairMobi
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
The problem is that if I set a default_entity_manager Doctrine is confused with entities from the first and second namespaces (Fire
and Leclair
) despite I see no error in my configuration.
For instance when trying to call a TblParaImp
entity from 'Fire' namespace (while default_entity_manager=leclair
is configured) I get errors like
[Doctrine\Persistence\Mapping\MappingException]
The class 'App\Entity\Fire\TblParaImp' was not found in the chain configured namespaces Ap
p\Entity\Leclair
or like
[Doctrine\Persistence\Mapping\MappingException]
The class 'App\Entity\Leclair\TImports' was not found in the chain configured namespaces App
\Entity\Fire
when trying to call a TImports
entity from 'Leclair' namespace while default_entity_manager=fire
is configured.
So I wonder what I missed in my configuration. Does anybody see where the error is ? Or at least tell me how to dump/debug Doctrine mapping, I couldn't find a way to do this.
Thanks a lot for any help or information.
Cheers