简体   繁体   中英

make:entity command: [ERROR] Only annotation mapping is supported by make:entity

When I am trying to create a new doctrine entity in Symfony 5.2 (maker-bundle v1.30.0) I get:

$ php bin/console make:entity

 Class name of the entity to create or update (e.g. GrumpyChef):
 > test

 created: src/Entity/Test.php
 created: src/Repository/TestRepository.php

                                                                                
 [ERROR] Only annotation mapping is supported by make:entity, but the           
         <info>App\Entity\Test</info> class uses a different format. If you     
         would like this command to generate the properties & getter/setter     
         methods, add your mapping configuration, and then re-run this command  
         with the <info>--regenerate</info> flag.

The files are generated and they look OK to me. I get the same for existing entities, except for the "created" lines. I have read about similar problems from years ago, but they were related to different namespaces which is not the case here, I am using the default namespace.

I believe the problem is related to an update, because of course it previously (not sure if it was 5.0 or 5.1) worked.

Is there any way to debug the MakerBundle or any idea how to solve this problem?

Thanks.

../config/packages/doctrine.yaml (I do not think I ever touched this):

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

        # IMPORTANT: You MUST configure your server version,
        # either here or in the DATABASE_URL env var (see .env file)
        #server_version: '5.7'
    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
$ php bin/console debug:config doctrine

Current configuration for extension with alias "doctrine"
=========================================================

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                url: '%env(resolve:DATABASE_URL)%'
                override_url: false
                driver: pdo_mysql
                logging: true
                profiling: true
                profiling_collect_backtrace: false
                profiling_collect_schema_errors: true
                options: {  }
                mapping_types: {  }
                default_table_options: {  }
                slaves: {  }
                replicas: {  }
                shards: {  }
        types: {  }
    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: default
        entity_managers:
            default:
                naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
                auto_mapping: true
                mappings:
                    App:
                        is_bundle: false
                        type: annotation
                        dir: <<root_path>>/src/Entity
                        prefix: App\Entity
                        alias: App
                        mapping: true
                query_cache_driver:
                    type: null
                metadata_cache_driver:
                    type: null
                result_cache_driver:
                    type: null
                class_metadata_factory_name: Doctrine\ORM\Mapping\ClassMetadataFactory
                default_repository_class: Doctrine\ORM\EntityRepository
                quote_strategy: doctrine.orm.quote_strategy.default
                entity_listener_resolver: null
                repository_factory: doctrine.orm.container_repository_factory
                hydrators: {  }
                filters: {  }
        proxy_dir: '%kernel.cache_dir%/doctrine/orm/Proxies'
        proxy_namespace: Proxies
        resolve_target_entities: {  }

https://github.com/symfony/maker-bundle/issues/841

symfony/maker-bundle v1.30.1 fixes it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM