phpweb-applicationsormarchitecturedatabase-abstraction

Advantages of using Doctrine for PHP?


Just came across the Doctrine Project which has an Object Relational Mapper and a DB Abstraction Layer. What does Doctrine provide that other PHP abstraction layers don't? And what practical use can you put the ORM to, apart from fetching objects via queries written in Doctrine Query Language? Is the query language really something you want to develop an entire web app in? Does it perform well?

On the whole does building an app on Doctrine make it easier to maintain and understand? Is it over-engineered, and is building on an abstraction layer sensible for small-medium size projects? (<50 GUI screens), as opposed to directly working with MySQL.


Solution

  • What does Doctrine provide that other PHP abstraction layers don't?

    1. Implements DataMapper pattern rather ActiveRecord.
    2. Supports annotations, XML and YAML for schema.
    3. Uses DQL.
    4. Uses benefits of PHP 5.3+.
    5. Is fast and has large community.
    6. Except ORM there is ODM.

    Is the query language really something you want to develop an entire web app in?

    Just a part of the application responsible for maintaining business-objects should be aware of the existence of Doctrine. And that part doesn't have to be 100% Doctrine-based.

    On the whole does building an app on Doctrine make it easier to maintain and understand?

    Definitely. The code is easier to read, understand and maintain.

    Is it over-engineered, and is it sensible for small-medium size projects?

    Actually Doctrine is quite simple in its fundamentals. And it's a very good choice for small, medium and even some large applications.


    Doctrine isn't the answer for everything and sometimes it's a little problematic. However for typical tasks it's extremely useful. IMHO the best ORM/ODM for PHP at this moment.