【发布时间】:2021-06-18 20:30:51
【问题描述】:
当我尝试在 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: { }
【问题讨论】:
-
同样的问题,上周我创建了一个网站骨架 sf 5.2.5,它成功了,今天早上创建一个新的并有这个问题。
-
您的映射配置是什么样的?
-
@PtrTon 我想这就是你的意思。我的 DATABASE_URL ServerVersion 实际上是错误的(我在使用 MariaDB 时指定了 5.7),但没有区别。
-
其实我指的是this
-
好的,我还添加了 debug:config 原则输出,不确定哪个条目可能感兴趣。
标签: php doctrine bundle symfony5