How to load doctrine fixtures if we have multiple databases and connections

I used this documentation : https://symfony.com/doc/4.4/doctrine/multiple_entity_managers.html

So now I can create new databases named legacy and Project like this

doctrince.yaml:

doctrine:
  dbal:
    default_connection: legacy
    connections:
      legacy:
        driver: pdo_mysql
        host: "%env(database_host)%"
        port: "%env(database_port)%"
        dbname: "%env(database_name)%"
        user: "%env(database_user)%"
        password: "%env(database_password)%"
        charset: UTF8
      project:
        driver: pdo_mysql
        host: "%env(database_host_project)%"
        port: "%env(database_port_project)%"
        dbname: "%env(database_name_project)%"
        user: "%env(database_user_project)%"
        password: "%env(database_password_project)%"
        charset: UTF8
  orm:
    default_entity_manager: legacy
    entity_managers:
      legacy:
        connection: legacy
        mappings:
          Legacy:
            is_bundle: false
            type: annotation
            dir: "%kernel.project_dir%/..."
            prefix: '...'
            alias: Legacy
      project:
        connection: project
        auto_mapping: true
        mappings:
          Project:
            is_bundle: false
            type: annotation
            dir: "%kernel.project_dir%/src/Entity"
            prefix: 'AppEntity'
            alias: Project

Now I have several Fixture classes all of them depend on each other and also some will create fixture for legacy and some will create for project.

Now my question is when I do:

php bin/console doctrine:fixtures:load --em=legacy

It runs the appfixtures of the project but not the of the bundle.
and then i get this error:

The class .. was not found in the chain configured namespaces ….

My question is now how can I load fixtures on multiple databases with multiple connections.
Thanks in advance.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *