作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试在 Symfony 5.2 (maker-bundle v1.30.0) 中创建一个新的 Doctrine 实体时,我得到:
$ 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.
文件已生成,对我来说它们看起来不错。除了“创建”行之外,我对现有实体也得到相同的结果。几年前我已经读过类似的问题,但它们与不同的命名空间有关,这里不是这种情况,我使用的是默认命名空间。
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 修复了它。
关于php - 制作 :entity command: [ERROR] Only annotation mapping is supported by make:entity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66741930/
我是一名优秀的程序员,十分优秀!