symfony找不到类”App\Entity\User”的实体管理器。

huangapple go评论55阅读模式
英文:

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"
```"

<details>
<summary>英文:</summary>

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 :
```bash
php bin/console make:user --is-entity --with-password
# it returns
In DoctrineHelper.php line 91:
                                                              
  Cannot find the entity manager for class &quot;App\Entity\User&quot;

答案1

得分: 2

根据 https://github.com/symfony/maker-bundle/issues/1158#issuecomment-1210446372 中提到的内容,在 config/packages/doctrine.yaml 中添加 type: attribute,就像这样:

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

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: &#39;%kernel.project_dir%/src/Entity&#39;
                prefix: &#39;App\Entity&#39;
                alias: App
                type: attribute

huangapple
  • 本文由 发表于 2023年3月31日 17:24:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896813.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定