-->

Invalid Argument Exception when generating Entitie

2019-06-22 07:38发布

问题:

I'm converting a Symfony 2 project from Propel to Doctrine and wish to convert the existing database into Doctrine Entities.

To do this I'm following the tutorial on the Symfony website, however when I run the following command:

php app/console doctrine:mapping:convert xml ./src/Acme/BlogBundle/Resources/config/doctrine/metadata/orm --from-database --force

I immediately receive the following error:

[InvalidArumentException]
Doctrine ORM Manager named "" does not exist.

Can anyone explain where I'm going wrong and how I go about fixing this?

回答1:

Finally found out what was causing the error. It appears that the doctrine configuration settings within config.yml require a parameter called auto_mapping: true.

For example:

doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
    orm:
        auto_mapping: true

More information can be found here: http://symfony.com/doc/2.0/reference/configuration/doctrine.html