Skip to content

Instantly share code, notes, and snippets.

@zburgermeiszter
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zburgermeiszter/ab113b8350448be13b31 to your computer and use it in GitHub Desktop.
Save zburgermeiszter/ab113b8350448be13b31 to your computer and use it in GitHub Desktop.
Rebuild single Doctrine entity
Fixed:
php app/console doctrine:mapping:import VendorDatabaseBundle yml --filter="Entityname"
php app/console doctrine:mapping:convert annotation ./src --namespace="Vendor\DatabaseBundle\Entity\\" --from-database --force --filter="Entityname"
php app/console doctrine:generate:entities VendorDatabaseBundle:Entityname
========================================================================
Rebuild single entity from DB.
According to this answer (I think the order of the commands are wrong in this answer):
http://stackoverflow.com/questions/10371600/generating-a-single-entity-from-existing-database-using-symfony2-and-doctrine
To IMPORT single table (rebuild entity config) (you should specify yml format somewhere):
php app/console doctrine:mapping:import AppMyBundle yml --filter="Yourtablename"
To convert to annotation (you should specify annonation mode somewhere)
php app/console doctrine:mapping:convert annotation ./src/App/MyBundle/Resources/config/doctrine --from-database --filter="Yourtablename"
And finally to rebuild (generate getters/setters) a single entity:
php app/console doctrine:generate:entities MyCustomBundle:User
OR
php app/console doctrine:generate:entities MyCustomBundle/Entity/User
WHOLE BUNDLE REBUILD
======================
To rebuild entity "configs"
php app/console doctrine:mapping:import --force AcmeBlogBundle yml
To convert them to PHP annotation format:
php app/console doctrine:mapping:convert annotation ./src
To regenerate getters and setters:
php app/console doctrine:generate:entities AcmeBlogBundle
http://symfony.com/doc/2.3/cookbook/doctrine/reverse_engineering.html
In theory it won't break anything if you modify the DB and rebuild the entities, BUT DON'T update the database FROM entities with doctrine, because it will break the DB compatibility with the legacy system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment