天天看點

symfony 從已有的資料庫中生成實體entity

php bin/console doctrine:mapping:import --force BundleName xml

這是基本的指令行 (bin/console) 也可換為(app/console),後面的--force 是強制生成并覆寫選項,可以不加,AcmeBlogBundle是所在bundle名 ,xml 是生成entity 的格式,可以為 xml,yml,annotation,看個人愛好自由選擇。

生成好entity 後如需對entity 中對應屬性生成getter,setter方法,可使用如下指令 :

php bin/console doctrine:generate:entities BundleName:EntityName