Monday, May 27, 2013

How to generate existing entity from existing databases - Symfony, Doctrine

To generate an entity, yes, an entity from a table in an existing database (in YAML):

1. Create a mapping file.

$ app/console doctrine:mapping:convert yml 
--from-database --force --filter=TableName --em=defaultEntityManager

2. Import annotation.
$ app/console doctrine:mapping:import BundleName annotation 
--filter=TableName --em=defaultEntityManager
3. Generate the entity.
$ app/console doctrine:generate:entitie Vendor/BundleName/Entity/EntityName 

No comments: