php - 使用 YAML 在 Symfony4 中映射实体
问题描述
想知道使用 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.
我为此做错了吗?
谢谢!
解决方案
推荐阅读
- zeromq - 在使用 ZeroMQ 的 majordomo 模式中是否有往返消息时间的标准,如何测量或找到该标准?
- reactjs - 单击导航栏中给出的链接时,如何在同一位置显示不同的 API 结果?
- javascript - 使用javascript检查var中的字符
- python - 如何在 PGPy 中使用公钥解密 PGP 文件
- django - 石墨烯错误消息
- javascript - 如何在 React Native 中使用 componentDidUpdate 和 shouldComponentUpdate?
- docker - VueCLI3 应用程序(nginx/docker)使用环境特定变量
- sql - 这个公式可以添加到 WHERE 子句中吗?
- java - 如何在 Eclipse 和/或 STS IDE 中启用自动重建 Spring Boot 项目
- python - 在 Python 中装饰方法期间传递“self”参数