使用YAML

时间:2018-07-21 11:48:56

标签: php symfony doctrine yaml

想知道使用YAML在另一个目录中映射实体的最佳方法是什么。我有一个像下面这样的树结构:

| src
|----User
|--------Domain
|------------Entity
|----------------User.php
|--------Infrastructure
|------------Resources
|----------------config
|--------------------doctrine
|-------------------------User.orm.yml

我的学说配置文件,看起来像这样一个:

parameters:
    env(DATABASE_URL): ''

doctrine:
    dbal:
        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.7'
        charset: utf8mb4
        default_table_options:
            charset: utf8mb4
            collate: utf8mb4_unicode_ci
        url: '%env(resolve:DATABASE_URL)%'

    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            User:
                is_bundle: false
                type: yml
                dir: '%kernel.project_dir%/src/User/Infrastructure/Resources/config/doctrine'
                prefix: 'App\User\Domain\Entity'
                alias: User

还有User.orm.yml映射文件:

App\User\Domain\Entity\User:
    type: entity
    table: users
    repositoryClass: App\User\Infrastructure\Persistance\Doctrine\DoctrineUserRepository
    id:
        id:
            type: integer
            generator:
                strategy: AUTO
    fields:
        password:
            type: string
            length: 64
            nullable: false
        email:
            type: string
            length: 255
            unique: true
            nullable: false

当我尝试通过键入以下内容来迁移架构时:bin/console doctrine:schema:update --force。 导致消息:

[OK] No Metadata Classes to process.

我为此做错了吗?

谢谢!

0 个答案:

没有答案