Is there a way to generate src\AppBundle\Resources\Config\doctrine\example.orm.yml file from an existing entity file src\AppBundle\Entity\Example.php, rather than use php bin/console doctrine:generate:entity to create a new entity?
-
This is such a useful feature for Symfony, however I was surprised to learn that Doctrine is removing this feature altogether soon! "...this feature to generate entities from existing databases will be completely removed in the next Doctrine version." symfony.com/doc/master/doctrine/reverse_engineering.htmlAaron Belchamber– Aaron Belchamber2018-04-02 16:50:18 +00:00Commented Apr 2, 2018 at 16:50
Add a comment
|
1 Answer
To Generate this file, you need something that doctrine can use to do it.
So if you have your database already up, you can do a
php bin/console doctrine:mapping:import
but if you want to do it "code first", i guess you need to create the mapping information yourself and then use
app/console generate:doctrine:entities <Your Bundle>
app/console doctrine:schema:update --dump-sql
app/console doctrine:schema:update --force
2 Comments
Michael Millar
thanks, yes there's always the option to make an orm.yml file manually but I was hoping there was a command that converted an existing entity php file to a orm.yml file (with no db table existing before that)
Maxime Thévenot
if your entity already have mapping informations (annotations), you can try
app/console doctrine:mapping:convert yml