World Library  
Flag as Inappropriate
Email this Article

Doctrine (PHP)

Article Id: WHEBN0016059445
Reproduction Date:

Title: Doctrine (PHP)  
Author: World Heritage Encyclopedia
Language: English
Subject: Comparison of web application frameworks, Icinga, Data mapper pattern, Object-relational mapping, Propel (PHP)
Collection: Object-Relational Mapping, Php Libraries, Php Programming Language
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Doctrine (PHP)

Doctrine
Stable release 2.5.0 / April 2, 2015 (2015-04-02)
Development status Active
Written in PHP
Operating system Cross-platform
Type Object-relational mapping framework
License MIT
Website .org.doctrine-projectwww

The Doctrine Project (or Doctrine) is a set of PHP libraries primarily focused on providing persistence services and related functionality. Its prize projects are an object-relational mapper (ORM) and the database abstraction layer it is built on top of.

One of Doctrine's key features is the option to write database queries in a proprietary object oriented SQL dialect called Doctrine Query Language (DQL).

Contents

  • Usage demonstration 1
  • Features 2
  • History 3
  • Influences 4
  • Community 5
  • See also 6
  • References 7
  • External links 8

Usage demonstration

Entities in Doctrine 2 are lightweight PHP Objects that contain persistable properties. A persistable property is an instance variable of the entity that is saved into and retrieved from the database by Doctrine’s data mapping capabilities via the Entity Manager - an implementation of the data mapper pattern:

 $user = new User();
 $user->name = "john1";
 $user->password = "doe";
 $entityManager->persist($user);
 $entityManager->flush();
 echo "The user with id $user->id has been saved.";

Doctrine 1.x follows the active record pattern for working with data, where a Class (computer science) corresponds with a database table. For instance, if a programmer wanted to create a new "User" object in a database, he/she would no longer need to write SQL queries, but instead could use the following PHP code:

 $user = new User();
 $user->name = "john";
 $user->password = "doe";
 $user->save();
 echo "The user with id $user->id has been saved.";

Features

One feature of Doctrine is the low level of configuration that is needed to start a project. Doctrine can generate object classes from an existing database, and the programmer can then specify relations and add custom functionality to the generated classes. There is no need to generate or maintain complex XML database schemas, as seen in many other frameworks.

Another key feature of Doctrine is the ability to optionally write database queries in an OO (object oriented) SQL dialect called DQL (Doctrine Query Language) inspired by Hibernate's HQL. Alternately, the QueryBuilder class (Doctrine_Query in Doctrine 1.x) allows one to construct queries through a fluent interface. These interfaces provide developers with powerful alternatives to SQL which maintain flexibility and still allow for switching of database back-ends, without requiring any code duplication.

Writing queries explicitly however is not always necessary, as Doctrine performs joins and fetches related objects automatically. Small projects can be easily constructed without writing queries.

Other notable features of Doctrine are:

  • support for hooks (methods which can validate or modify database input and output) and event listeners to structure business-related logic;
  • column aggregation inheritance (similar objects can be stored in one database table, with one type-column specifying the subtype of the particular object - the correct subclass is always returned when a query is done);
  • a caching framework, making use of several backends such as memcached, SQLite or APC;
  • ACID transactions;
  • database migrations;
  • a "compile" function to combine many PHP files of the framework into one, to avoid the performance hit usually incurred by including the many PHP files of a framework.

History

Doctrine was started by Konsta Vesterinen, also known as zYne-. The project's initial commit was made on April 13, 2006. As the project became more mature, the adoption began to pick up. Before long, the community was active and development was receiving regular contributions, among others from the Google Summer of Code project.

Doctrine 1.0.0 was released on September 1, 2008.[1]

The first stable version of Doctrine 2.0 was released on December 22, 2010, after 2.5 years of dedicated development starting in early 2008.[2]

Influences

Doctrine has been influenced by dozens of projects and many different people. The largest influences have been the Java ORM Hibernate and ActiveRecord from Ruby on Rails. Both of these ORM solutions have implemented a fully featured solution in the Java and Ruby languages. The purpose of the Doctrine project is to build an equally powerful solution for the PHP language for high-load websites that have to maintain constant flow of visitors. Doctrine ORM can be used to improve performance of such websites.

Community

  • There is an active IRC channel where users and developers of Doctrine commonly associate. The channel is on the freenode network (irc.freenode.net); the channel name is #doctrine.
  • User mailing list: http://groups.google.com/group/doctrine-user
  • Development mailing list: http://groups.google.com/group/doctrine-dev

See also

References

  1. ^ Doctrine 1.0.0 released
  2. ^ Doctrine 2 First Stable Release

External links

  • Official website
  • Doctrine GitHub repositories
  • Doctrine Documentation
  • Official blog
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.