Symfony3.4 数据库反向生成entity 已解决
映射数据库结构到文件(php\xml\yaml)
### 映射数据库结构到文件(php\xml\yaml)
[root@localhost ~]# cd /windows/www/symfony_test/
[root@localhost symfony_test]# php bin/console doctrine:mapping:import --force AppBundle php
Importing mapping information from "default" entity manager> writing /windows/www/symfony_test/src/AppBundle/Resources/config/doctrine/Feedback.orm.php> writing /windows/www/symfony_test/src/AppBundle/Resources/config/doctrine/User.orm.php> writing /windows/www/symfony_test/src/AppBundle/Resources/config/doctrine/User.orm.php### 生成entity
[root@localhost symfony_test]# php bin/console doctrine:mapping:convert annotation ./srcProcessing entity "AppBundle\Entity\Feedback"Processing entity "AppBundle\Entity\User"Processing entity "AppBundle\Entity\User"Exporting "annotation" mapping information to "/windows/www/symfony_test/src"
[root@localhost symfony_test]#
[root@localhost symfony_test]# tree src/
src/
└── AppBundle├── AppBundle.php├── Controller│ ├── DefaultController.php│ └── UserController.php├── Entity│ └── User.php├── Repository│ ├── DemoRepository.php│ └── UserRepository.php├── Resources│ └── config│ └── doctrine│ ├── User.orm.php└── Serverice└── UserService.php
entity生成后,需要自己使用IDE工具生成getters和setters方法, 以及一些关联关系, 验证Assert提示信息
注意entity定义字段的格式,@var string|null必须要写,不然会找不到该字段
php bin/console doctrine:generate:entities AppBundle/Entity/Users
php bin/console doctrine:mapping:import --force RelBundle annotation生成get,set 自定义库
php bin/console doctrine:generate:entities RelBundle
php app/console doctrine:mapping:import "YourAppBundle" annotation --em=show --filter=DownloadRankingCoefficient
php app/console doctrine:generate:entities --no-backup YourAppBundle:DownloadRankingCoefficient
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
