原作者地址:https://www.it603.com/article/88.html

参考文章:

https://symfony.com/doc/current/doctrine/reverse_engineering.html How to Generate Entities from an Existing Database

https://www.jianshu.com/p/75fc86ec98aa symfony 创建数据库映射时报错: Unknown database type enum requested

https://codeday.me/bug/20181110/383025.html symfony – Doctrine2忽略数据库表

 

基础命令:

php bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity

App\Entity 命名空间

annotation 生成方式

--path 生成路径

生成getter/setter方法

php bin/console make:entity --regenerate  App\\Entity\\UserModule

 

可能出现的问题:

1、不想生成全部表

添加参数进行过滤,过滤的是匹配类名 --filter=User

2、过滤不符合规则的表

修改doctrine配置,过滤表,添加 

schema_filter: ~^(?!Table1)~

3、提示数据类型不支持

修改doctrine配置,添加类型映射表,添加 

mapping_types:
   enmu : string
   set : string
   varbinary : string
   tinyblob: text

4、数据库表太多,仅生成想要的表

修改doctrine配置,schema_filter规则临时仅允许特定表

: ~^(user)$~

这里面的user表是自己的

 

最终样例如下:

【转载】 symfony 生成实体类命令

【转载】 symfony 生成实体类命令

相关文章:

  • 2021-07-28
  • 2022-12-23
  • 2022-02-01
  • 2021-10-20
  • 2021-12-06
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-13
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
相关资源
相似解决方案