3

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?

1
  • 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.html Commented Apr 2, 2018 at 16:50

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

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)
if your entity already have mapping informations (annotations), you can try app/console doctrine:mapping:convert yml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.