我是Symfony 4
的新手我使用Doctrine,我想使用 yaml 实体映射。
所以我配置了文件doctrine.yaml
并将type:annotation
更改为type:yml
。
当我尝试php bin/console make:entity
时,没有生成链接到此实体的yaml映射文件
这是我的doctrine.yaml
文件:
parameters: # Adds a fallback DATABASE_URL if the env var is not set. # This allows you to run cache:warmup even if your # environment variables are not available yet. # You should not need to change this value. env(DATABASE_URL): '' doctrine: dbal: # configure these for your database server driver: 'pdo_mysql' server_version: '5.7' charset: utf8mb4 # With Symfony 3.3, remove the `resolve:` prefix url: '%env(resolve:DATABASE_URL)%' orm: auto_generate_proxy_classes: '%kernel.debug%' naming_strategy: doctrine.orm.naming_strategy.underscore auto_mapping: true mappings: App: is_bundle: false type: yml dir: '%kernel.project_dir%/src/Entity' prefix: 'App\Entity' alias: App
答案 0 :(得分:5)
根据您的需求进行映射的示例:
更改文件名,包括" orm "文字doctrine.orm.yaml
,并查看以下示例中的dir
选项(符合您的需求):
App:
is_bundle: false
type: yml
# "dir" in this case must be pointed where are stored your doctrine files (can be anywhere inside the project dir)
dir: "%kernel.project_dir%/config/doctrine"
prefix: App\Entity