Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate entities from database schema using doctrine-orm-module and zf2

Tags:

I am using "doctrine/doctrine-orm-module": "0.7.0" with ZF2.

Once I create Entities I usually run following commands to sync and generate database automatically according to my entities.

./vendor/bin/doctrine-module orm:validate-schema
./vendor/bin/doctrine-module orm:schema-tool:create

Is there a way to make this process reverse? I mean, Can I generate entities from existing database in mysql?

like image 738
Developer Avatar asked Aug 27 '13 10:08

Developer


1 Answers

We use a batch script:

@ECHO OFF

mkdir EXPORT
call .\vendor\bin\doctrine-module orm:convert-mapping --force --from-database annotation ./EXPORT/
call .\vendor\bin\doctrine-module orm:generate-entities ./EXPORT/ --generate-annotations=true

pause 

orm:convert-mapping and orm:generate-entities is probably what you are looking for.

like image 92
cptnk Avatar answered Oct 18 '22 14:10

cptnk