4

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

  • The object (e.g. User)
  • The Peer (e.g. UserPeer)
  • The Query (e.g. UserQuery)

The object class (User) includes getters and setters for all of the attributes. E.g.

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

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

1 Answer 1

1

Yes Doctrine 2 does support schema to class generation, I prefer YAML over XML so here's the link covering that http://www.doctrine-project.org/docs/orm/2.0/en/reference/yaml-mapping.html

AND then via 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 does have simple setters/getters but they're called accessor methods in Doctrine terminology.

Update:

For completely generated classes, give a table like

user:
   id: integer   
   name: string
   active: bool

it would 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 out this file in the Doctrine 2 git repo https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Tools/EntityGenerator.php

2
  • Thanks! - What do the accessor methods look like? Are they added to the generated classes by default?
    – 0x6A75616E
    May 10, 2011 at 19:37
  • It's important to note that Doctrine 1 & 2 require APC and or Memcache to be efficient.
    – David
    May 10, 2011 at 20:26

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.