這玩意搞得挺蛋疼,後邊仔細看了下文檔發現還是挺簡單的,只需要三步就生成了
1:在src\AppBundle\Resources\config\doctrine文件下生成xml字段映射文件,比如:Test.orm.xml
php bin/console doctrine:mapping:import AppBundle xml 這個命令會把默認連接數據庫裏的所有表都在src\AppBundle\Resources\config\doctrine目錄裏生成xml文件
如果想要只生成一個表的xml文件只需要加個--filter參數:
php bin/console doctrine:mapping:import AppBundle --filter=Test xml Test是表名,第一個字母大寫
如果是其他庫連接的話可以這樣:比如customer連接名稱
php bin/console doctrine:mapping:import --force AppBundle xml --em=customer(數據庫連接名稱)
2:生成Entity目錄和test表的字段php文件
php bin/console doctrine:mapping:convert annotation ./src
或者只生成某個庫連接:php bin/console doctrine:mapping:convert annotation ./src --em=customer
如果只生成某個表的Entity實體文件:php bin/console doctrine:mapping:convert annotation --filter=UserLog ./src --em=customer
3:生成set get方法
php bin/console doctrine:generate:entities AppBundle --no-backup Entity目錄裏的文件都生成set get方法
或者只想給某個文件生成:
php bin/console doctrine:generate:entities AppBundle/Entity/Blog --no-backup