Doctrine can generate entities based on small data input, including relation information. However, i have failed to find any example or concise information on the topic. The official documentation only has a small paragraph, with a minor command line example, explaining absolutely nothing,
Can anyone refer to a book, article or even code sample of this?
I usually declare the metadata in yml, and initially generate classes and database from there.
Here is a complete example along with the yml metadata files:
And the example schema files: YAML schema for module1:
YAML Schema for module 2:
Please note that I was using the SimplifiedYamlDriver Metadata driver that can load multiple entities from a single yml file.
This is a working example, I use these exact steps for generating class files and db from yml. Additionally, the Getting Started tutorial contains quite several yml examples.
First you need to bootstrap
Doctrine
and get an instance ofEntityManager
, then you once you have it, you can do the following:For more information on the configuration, read this:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html