如何配置 Doctrine 以在 Symfony 4 上使用 yaml 映射
How to configure Doctrine to use yaml mapping on Symfony 4
我是 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
根据您的需要进行映射的示例:
更改文件名,包括“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
我是 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
根据您的需要进行映射的示例:
更改文件名,包括“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