php 依赖于不存在的服务“doctrine.orm.metadata.annotation_reader”

kt06eoxx  于 2023-01-04  发布在  PHP
关注(0)|答案(1)|浏览(162)

所以我有一个Symfony 6.2 API,PHP 8.2代码库。
当尝试运行composer安装/更新时,显示以下错误,我想知道如何清除它:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 83:
The service "doctrine.orm.default_annotation_metadata_driver" has a dependency 
on a non-existent service "doctrine.orm.metadata.annotation_reader".

如果我注解掉doctry.yaml文件中的mappings部分(如下所示),composer将成功运行,但是所有对API的POST请求都将导致以下错误:

Could not find the entity manager for class App\Entity\Token.
Check your Doctrine configuration to make sure it is configured 
to load this entity’s metadata. (500 Internal Server Error)

抓着我的头想知道如何解决它。我有一种感觉,这可能是教义。yaml相关,但我可能是英里偏离马克。
composer.json:

"require": {
        "php": ">=8.2",
        ...
        "doctrine/doctrine-bundle": "^2.8",
        "doctrine/doctrine-migrations-bundle": "^3.2",
        "doctrine/orm": "^2.14",
        ...
    },

doctrine.yaml:

doctrine:
    dbal:
        url: '%env(resolve:DATABASE_URL)%'

    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
vlju58qv

vlju58qv1#

尝试在composer.json文件中添加:

doctrine/annotations

相关问题