I am in the process of upgrading from Doctrine 1.1.4 to Doctrine 2.0.6 in my Zend application. I have installed the Doctrine 2 command line tool.
In Doctrine 1.1.4, I generated the model classes directly from the database (using Doctrine::generateModelsFromDb()), is this possible in Doctrine 2, or do I have to go through the 'mapping' process i.e. by providing Docblock Annotations, XML or YAML structures of the tables.
The reason I ask this is because there is a 'setAutoGenerateProxyClass' option in Doctrine 2, I got the impression that this means it will generate the proxy classes from scratch.
Appreciate the help.
Autogenerate proxyclasses means basically that Doctrine 2 will automatically generate "proxy classes" for your entities, instead of only generating them manually using generate-proxies. Proxies are used when you have relations in your entities and they need to be lazy-loaded.
To generate mapping information from the database, you can use convert-mapping:
php doctrine orm:convert-mapping --from-database yml /path/to/mapping-path-converted-to-yml
Bear in mind that this is only recommended to be used as a starting point. The database driver is not able to correctly generate mappings for all possible combinations of options, so you probably should just run this once and then write mappings yourself.
See Doctrine 2 manual, "Reverse Engineering the database"
You can use the "annotation" as driver, if you want to get the generated entities:
php doctrine orm:convert-mapping --from-database annotation generatedModels
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With