Does Doctrine 2.0 represent predefined model classes such as Propel 1.5?

Propel can generate classes based on a schema file. Some of the classes received:

  • Object (e.g. User)
  • Peer (e.g. UserPeer)
  • Query (e.g. UserQuery)

The object class (User) includes getters and setters for all attributes. For instance.

$user = new User(); echo $user->getEmailAddress(); 

My question is: can Doctrine 2.0 do this? Does it create base classes and add getters and setters?

+4
source share
1 answer

Yes, Doctrine 2 supports a scheme for generating a class, I prefer YAML over XML, so the link covering this is http://www.doctrine-project.org/docs/orm/2.0/en/reference/yaml-mapping.html

And then using the Doctrine command line tools, you can take the provided YML files and generate http://www.doctrine-project.org/docs/orm/2.0/en/reference/tools.html

As for your second question, for the most part Doctrine has simple setters / getters, but they are called access methods in Doctrine terminology.

Update:

For fully generated classes, give a table like

 user: id: integer name: string active: bool 

it will be $ user-> getName () and $ user-> setName ("Joe"), $ user-> setActive (true) and $ user-> getActive ();

How it generates these intermediate classes can be somewhat understood by checking this file in Doctrine 2 git repo https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/EntityGenerator.php

+1
source

All Articles