make:entity 命令:[错误] make:entity 仅支持注释映射
make:entity command: [ERROR] Only annotation mapping is supported by make:entity
当我尝试在 Symfony 5.2 (maker-bundle v1.30.0) 中创建一个新的学说实体时,我得到:
$ 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.
文件已生成,我认为它们没问题。对于现有实体,我得到相同的结果,除了“创建”的行。我从几年前就读到过类似的问题,但它们与不同的命名空间有关,这里不是这种情况,我使用的是默认命名空间。
我认为问题与更新有关,因为当然它以前(不确定是 5.0 还是 5.1)有效。
有什么方法可以调试 MakerBundle 或解决这个问题的想法吗?
谢谢。
../config/packages/doctrine.yaml(我想我从来没有碰过这个):
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 修复了它。
当我尝试在 Symfony 5.2 (maker-bundle v1.30.0) 中创建一个新的学说实体时,我得到:
$ 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.
文件已生成,我认为它们没问题。对于现有实体,我得到相同的结果,除了“创建”的行。我从几年前就读到过类似的问题,但它们与不同的命名空间有关,这里不是这种情况,我使用的是默认命名空间。
我认为问题与更新有关,因为当然它以前(不确定是 5.0 还是 5.1)有效。
有什么方法可以调试 MakerBundle 或解决这个问题的想法吗?
谢谢。
../config/packages/doctrine.yaml(我想我从来没有碰过这个):
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 修复了它。