A free and open-source book about Zend Framework


Doctrine Architecture

The Doctrine Project consists of several libraries (components). Each Doctrine component is distributed as a Composer-installable package and registered in Packagist.org catalogue. This is very similar to the way that Zend Framework 3 uses for installing its components.

Here we will provide you with a brief description of Doctrine library architecture to let you a general idea of its capabilities.

Components Supporting Relational Databases

Main Doctrine components designed for working with relational databases are shown in figure D.2 and marked with green. Blue blocks denote the PHP engine and PHP extensions Doctrine is built on top of.

Figure D.2. Doctrine components designed for working with relational databases Figure D.2. Doctrine components designed for working with relational databases

As you can see from the figure, Doctrine is based on PHP engine features and on PHP extensions that are actually used as drivers to particular database management systems. Above that base layer, there are core Doctrine components (like Annotations, Common, etc.) providing essential functionality for other top-level components. The DBAL component provides an abstraction layer of database type. And on top of all that there is the ORM component providing API for working with data in object-oriented way. DoctrineModule and DoctrineORMModule components are designed for integration with Zend Framework 3.

Doctrine ORM component uses the so called Data Mapper pattern. This pattern tells that a database table can be represented as a PHP entity class. The database in this pattern is considered as some kind of repository (storage of entities). When you retrieve an entity from the repository, an SQL query is performed internally, and an instance of the PHP entity class is constructed and its properties are filled with data.

By analogy with ZF3 components, Doctrine component names consist of two parts: the vendor name ("Doctrine") and the component name (e.g. "Common"). Below, you can find the list of Doctrine components together with their Composer-installable package names and brief descriptions:

Since Doctrine uses PHP autoloading and PSR-4 standard, classes belonging to certain component live in that component's namespace. For example, the EntityManager class belonging to Doctrine\ORM component, lives in Doctrine\ORM namespace.

Components Supporting NoSQL Document Databases

Doctrine components designed for working with NoSQL document databases (MongoDB, CouchDB, etc.) are shown in figure D.3 and marked with green. Blue blocks denote the PHP engine and PHP extensions Doctrine is built on top of.

Figure D.3. Doctrine components designed for working with document databases Figure D.3. Doctrine components designed for working with document databases

As you can see from the figure D.3, Doctrine NoSQL components are based on PHP engine features and on PHP extensions that can be considered as "drivers" to particular database management systems. Above that base layer, there are middle level components. The Common component is the same component that was shown in figure D.2; it provides commonly used functionality. The MongoDB and CouchDB are components providing low-level API to corresponding databases. The MongodbODM, CouchdbODM, OrientdbODM and PhpcrODM components provide Object Document Mappers (ODM) for corresponding databases. ODM concept is very similar to ORM in sense that it provides an ability to work with a NoSQL database in object oriented way by mapping a document to a PHP entity class. The DoctrineMongoODMModule component is intended for integration with ZF3.

Below, you can find the list of components together with their Composer-installable package names and brief descriptions:


Top