by doctrine

Doctrine ORM Module for Laminas

406 Stars 232 Forks Last release: 4 months ago (3.0.5) MIT License 943 Commits 51 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Doctrine 2 ORM Module for Laminas

Master branch build status Code Coverage Latest Stable Version Total Downloads

DoctrineORMModule integrates Doctrine 2 ORM with Laminas quickly and easily.

  • Doctrine 2 ORM support
  • Multiple ORM entity managers
  • Multiple DBAL connections
  • Reuse existing PDO connections in DBAL connection


Installation of this module uses composer. For composer documentation, please refer to

composer require doctrine/doctrine-orm-module

Then add

to your
and create directory
and make sure your application has write access to it.

Installation without composer is not officially supported and requires you to manually install all dependencies that are listed in


Entities settings

To register your entities with the ORM, add following metadata driver configurations to your module (merged) configuration for each of your entities namespaces:

        'driver' => [
            // defines an annotation driver with two paths, and names it `my_annotation_driver`
            'my_annotation_driver' => [
                'class' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class,
                'cache' => 'array',
                'paths' => [

        // default metadata driver, aggregates all other drivers into a single one.
        // Override `orm_default` only if you know what you're doing
        'orm_default' => [
            'drivers' => [
                // register `my_annotation_driver` for any entity under namespace `My\Namespace`
                'My\Namespace' => 'my_annotation_driver',


Connection settings

Connection parameters can be defined in the application configuration:

        'connection' => [
            // default connection name
            'orm_default' => [
                'driverClass' => \Doctrine\DBAL\Driver\PDOMySql\Driver::class,
                'params' => [
                    'host'     => 'localhost',
                    'port'     => '3306',
                    'user'     => 'username',
                    'password' => 'password',
                    'dbname'   => 'database',

Full configuration options

An exhaustive list of configuration options can be found directly in the Options classes of each module.

You can find documentation about the module's features at the following links:

Registered Service names

  • doctrine.connection.orm_default
    : a
  • doctrine.configuration.orm_default
    : a
  • doctrine.driver.orm_default
    : default mapping driver instance
  • doctrine.entitymanager.orm_default
    : the
  • Doctrine\ORM\EntityManager
    : an alias of
  • doctrine.eventmanager.orm_default
    : the

Command Line

Access the Doctrine command line as following


Service Locator

To access the entity manager, use the main service locator:

// for example, in a controller:
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
$em = $this->getServiceLocator()->get(\Doctrine\ORM\EntityManager::class);

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.