如何配置Doctrine以在Symfony 4上使用yaml映射

Ny *_*ina 6 mapping yaml symfony doctrine-orm symfony4

我是Symfony 4的新手

我使用Doctrine,我想使用yaml实体映射.所以我配置了文件doctrine.yaml并更改type:annotationtype: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

gp_*_*ver 6

根据您的需求进行映射的示例:

更改包含“ 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
Run Code Online (Sandbox Code Playgroud)

参考:教义Yaml映射(v2.6当前)