views:

32

answers:

2

Hi,

I am investigating Doctrine 2 for PHP and I am having trouble finding good resources for how to map using the PHPDriver. There is extensive documentation on using Annotations in comments for the Doctrine mappings, however, I would rather have my mapping definitions in PHP and NOT in comments (for obvious reasons).

I could use some examples mainly with association mapping. The documentation using Annotations doesn't really help me much. Using those I seem to be left guessing through trial and error on how to do it with the PHPDriver.

Does anyone know of a good reference off hand? Any help would be greatly appreciated.

A: 

If you haven't seen it already, there is a section on PHPDriver in the Doctrine manual now:

The manual gets updated quite frequently, so keep checking back for new topics. You may also want to consult the API documentation directly:

The general terminology and conventions used by all the mapping drivers are the same, so the basic ideas should translate. It's probably syntax that will trip you up.

I would also recommend you look into the XML driver as well. With a good IDE, you can get validation and auto-completion via the xsd file, which makes it easier. Writing out PHP mappings by hand personally strikes me as a bit labor intensive.

Bryan M.
Thanks for the response, but I have already seen that, and the examples are very limited. I have managed to derive enough to get by solely on translating the annotation examples, but I was hoping for a page that provided examples of mappings using the PHPDriver.
Zoidberg
A: 

The PHP Drivers were rather low priority for now and until we add the programmatic builder that simplifies the PHP mapping it will probably keep being neglected vs annotations/xml/yaml.

However you will find a good example in the unittests (tests/Doctrine/Tests/ORM/Mapping) somehwere.

beberlei