symfonysymfony5

symfony Cannot find the entity manager for class "App\Entity\User"


After upgrade to last symfony 5.4 update, I remove user entity/repository to restart and remove all deprecations.

To recreate User entity/repository, I run :

php bin/console make:user --is-entity --with-password
# it returns
In DoctrineHelper.php line 91:
                                                              
  Cannot find the entity manager for class "App\Entity\User"

Solution

  • as mentionned in https://github.com/symfony/maker-bundle/issues/1158#issuecomment-1210446372,
    add in config/packages/doctrine.yaml type: attribute like that :

    # config/packages/doctrine.yaml
            mappings:
                App:
                    is_bundle: false
                    dir: '%kernel.project_dir%/src/Entity'
                    prefix: 'App\Entity'
                    alias: App
                    type: attribute