PHPackages                             streamcommon/doctrine-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. streamcommon/doctrine-manager

ActiveLibrary[Database &amp; ORM](/categories/database)

streamcommon/doctrine-manager
=============================

Doctrine 2 container interop

1.2.6(3y ago)15.1k2[2 PRs](https://github.com/streamcommon/doctrine-manager/pulls)BSD-3-ClausePHPPHP ^7.3 || ^8.0

Since Feb 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/streamcommon/doctrine-manager)[ Packagist](https://packagist.org/packages/streamcommon/doctrine-manager)[ RSS](/packages/streamcommon-doctrine-manager/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (18)Versions (25)Used By (0)

doctrine-manager
================

[](#doctrine-manager)

[![Latest Stable Version](https://camo.githubusercontent.com/38de45ac2b8dd41ec30aec9e1426f1c90fc9ab36b7f76aec42372e25b2b7c987/68747470733a2f2f706f7365722e707567782e6f72672f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722f762f737461626c65)](https://packagist.org/packages/streamcommon/doctrine-manager)[![Total Downloads](https://camo.githubusercontent.com/493ac480206f57b15d36038349a74685bc89f59481569ba56531f7e4f170037f/68747470733a2f2f706f7365722e707567782e6f72672f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722f646f776e6c6f616473)](https://packagist.org/packages/streamcommon/doctrine-manager)[![License](https://camo.githubusercontent.com/6ec6a50bce98994f1fd737f080cf10e4b327b5e030bc3ea4a19871565c73566a/68747470733a2f2f706f7365722e707567782e6f72672f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722f6c6963656e7365)](./LICENSE)

This package provide [Doctrine 2](https://github.com/doctrine) factories for [PRS-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md) container standard.

Branches
========

[](#branches)

[![Master](https://camo.githubusercontent.com/3fa4dd6b22d6ba39b4a6124ce262c7035f01b66bbcdce677bdbdb53665592249/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6272616e63682d6d61737465722d626c75652e737667)](https://github.com/streamcommon/doctrine-manager/tree/master) [![Build Status](https://camo.githubusercontent.com/d4407df105adf87c3e5f0cbe61064f29b8009d7688f913738f3feab64ca318e9/68747470733a2f2f7472617669732d63692e6f72672f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/streamcommon/doctrine-manager) [![Coverage Status](https://camo.githubusercontent.com/e8598764ef03c59ca40cd0e381e3bb04537430776a2e76e40ce9cf187908e613/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/streamcommon/doctrine-manager?branch=master)

[![Develop](https://camo.githubusercontent.com/f9833e2ebd3338a783a834689428f7716e095680ae37b48ae7a950e73deef3f2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6272616e63682d646576656c6f702d626c75652e737667)](https://github.com/streamcommon/doctrine-manager/tree/develop) [![Build Status](https://camo.githubusercontent.com/e0a8dac0bdb4f1b41d31568e92d45f5c75efbc07c328e9787302dcd594579e12/68747470733a2f2f7472617669732d63692e6f72672f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/streamcommon/doctrine-manager) [![Coverage Status](https://camo.githubusercontent.com/b829893c52426f698bb32147466f82a05d7515082d0c217b693e2f29ccb586fc/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73747265616d636f6d6d6f6e2f646f637472696e652d6d616e616765722f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/streamcommon/doctrine-manager?branch=develop)

Installation
------------

[](#installation)

Console run:

```
    composer require streamcommon/doctrine-manager
```

Or add into your `composer.json`:

```
    "require": {
        "streamcommon/doctrine-manager": "*"
    }
```

Please check doctrine documentation for more info
-------------------------------------------------

[](#please-check-doctrine-documentation-for-more-info)

- [ORM version 2.6](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/index.html)
- [DBAL version 2.9](https://www.doctrine-project.org/projects/doctrine-dbal/en/2.9/index.html)
- [Migrations version 2.1](https://www.doctrine-project.org/projects/doctrine-migrations/en/2.1/index.html)
- [Event Manager version 1.0](https://www.doctrine-project.org/projects/doctrine-event-manager/en/latest/index.html)
- [Metadata driver](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/metadata-drivers.html#metadata-drivers)
- [ORM Events](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/events.html)
- [Doctrine Annotation &gt;1.6](https://www.doctrine-project.org/projects/doctrine-annotations/en/1.6/index.html)
- [Caching](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/caching.html)
- [Entity Manager](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/working-with-objects.html)
- [ZendFramework/zend-servicemanager](https://github.com/zendframework/zend-servicemanager)
- [ZendFramework/zend-auradi-config](https://github.com/zendframework/zend-auradi-config)
- [ZendFramework/zend-pimple-config](https://github.com/zendframework/zend-pimple-config)
- [Jsoumelidis/zend-sf-di-config](https://github.com/jsoumelidis/zend-sf-di-config)
- [Laminas/laminas-servicemanager](https://github.com/laminas/laminas-servicemanager)
- [Laminas/laminas-auradi-config](https://github.com/laminas/laminas-auradi-config)
- [Laminas/laminas-pimple-config](https://github.com/laminas/laminas-pimple-config)

Example configure project file
------------------------------

[](#example-configure-project-file)

> `Psr\Container\ContainerInterface` container MUST have `config` key

Configure your project config file:

1. Configure doctrine configuration like: ```
    'config' => [
        'doctrine' => [
            'configuration' => [
            // If you use single connection
                'orm_default' => [
                    'result_cache' => 'array',
                    'metadata_cache' => 'array',
                    'query_cache' => 'array',
                    'hydration_cache' => 'array',
                    'driver' => 'orm_default',
                ],

            // If you want to add a second connection
                'orm_custom' => [
                    'result_cache' => 'memcached',
                    'metadata_cache' => 'memcached',
                    'query_cache' => 'memcached',
                    'hydration_cache' => 'memcached',
                    'driver' => 'orm_custom',
                ],
            ],
    ```
2. Configure connection options like: ```
            'connection' => [
            // If you use single connection
            // Default using MySql connection
                'orm_default' => [
                    'configuration' => 'orm_default',
                    'event_manager' => 'orm_default',
                    'params' => [
                        'dbname' => 'name',
                        'user' => 'user',
                        'password' => 'password',
                        'host' => 'localhost',
                    ],
                ],

            // If you want to add a second connection
            // Alternative Postgress connection
                'orm_custom' => [
                    'configuration' => 'orm_custom',
                    'event_manager' => 'orm_custom',
                    'driver_class_name' => \Doctrine\DBAL\Driver\PDOPgSql\Driver::class,
                    'params' => [
                        'dbname' => 'name',
                        'user' => 'user',
                        'password' => 'password',
                        'host' => 'localhost_custom',
                    ],
                ]
            ],
    ```
3. Configure entity|event manager: ```
            'entity_manager' => [
                'orm_default' => [
                    'connection' => 'orm_default',
                    'configuration' => 'orm_default',
                ],
                'orm_custom' => [
                    'connection' => 'orm_custom',
                    'configuration' => 'orm_custom',
                ]
            ],
            'event_manager' => [
                'orm_default' => [
                    'subscribers' => [],
                ],
                'orm_custom' => [
                    'subscribers' => [],
                ]
            ],
            'entity_resolver' => [
                'orm_default' => [
                    'resolvers' => [],
                ],
                'orm_custom' => [
                    'resolvers' => [],
                ],
            ],
    ```
4. Configure orm driver, for example: ```
            'driver' => [
             // If you use single connection
             // Annotation driver example
             //@see https://www.doctrine-project.org/projects/doctrine-annotations/en/1.6/index.html
                'orm_default' => [
                    'class_name' => \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class,
                    'drivers' => [
                       'Annotation\Entity' => 'Annotation\Entity'
                    ],
                ],
                'Annotation\Entity' => [
                    'class_name' => \Doctrine\ORM\Mapping\Driver\AnnotationDriver::class,
                    'paths' => [
                        __DIR__ . '/Annotation/Entity'
                    ]
                ],

            // If you want to add a second connection
            // Php driver for example
                'orm_custom' => [
                    'class_name' => \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain::class,
                    'drivers' => [
                        'PHPDriver\Entity' => 'PHPDriver\Entity'
                    ],
                ],
                'PHPDriver\Entity' => [
                    'class_name' => \Doctrine\Common\Persistence\Mapping\Driver\PHPDriver::class,
                    'paths' => [
                        __DIR__ . '/PHPDriver/Entity'
                    ]
                ],
            ],
    ```
5. Configure doctrine cache: ```
    //@see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/caching.html
            'cache' => [
                'array' => [
                    'class_name' => Doctrine\Common\Cache\ArrayCache::class,
                    'namespace' => 'Streamcommon\Doctrine\Manager\Interop',
                ]
            ],
        ]
    ],
    ```
6. Configure your project dependencies: ```
    use Streamcommon\Doctrine\Manager\Common\Factory\{
        Cache as CacheFactory,
        Driver as DriverFactory,
        EventManager as EventManagerFactory
    };
    use Streamcommon\Doctrine\Manager\DBAL\Factory\Connection as ConnectionFactory;
    use Streamcommon\Doctrine\Manager\ORM\Factory\{
        Configuration as ConfigurationFactory,
        EntityManager as EntityManagerFactory,
        EntityResolver as EntityResolverFactory,
    };

    'dependencies' => [
       'factories' => [
       // If you use single connection
            'doctrine.driver.orm_default'          => [DriverFactory::class, 'orm_default'],
            'doctrine.event_manager.orm_default'   => [EventManagerFactory::class, 'orm_default'],
            'doctrine.configuration.orm_default'   => [ConfigurationFactory::class, 'orm_default'],
            'doctrine.connection.orm_default'      => [ConnectionFactory::class, 'orm_default'],
            'doctrine.entity_resolver.orm_default' => [EntityResolverFactory::class, 'orm_default'],
            'doctrine.entity_manager.orm_default'  => [EntityManagerFactory::class, 'orm_default'],
            'doctrine.cache.array'                 => [CacheFactory::class, 'orm_default'],

       // If you want to add a second connection
            'doctrine.driver.orm_custom'          => [DriverFactory::class, 'orm_custom'],
            'doctrine.event_manager.orm_custom'   => [EventManagerFactory::class, 'orm_custom'],
            'doctrine.configuration.orm_custom'   => [ConfigurationFactory::class, 'orm_custom'],
            'doctrine.connection.orm_custom'      => [ConnectionFactory::class, 'orm_custom'],
            'doctrine.entity_resolver.orm_custom' => [EntityResolverFactory::class, 'orm_custom'],
            'doctrine.entity_manager.orm_custom'  => [EntityManagerFactory::class, 'orm_custom'],
        ],
    ]
    ```
7. Use in your project: ```
    $em = $container->get('doctrine.entity_manager.orm_default');
    $connection = $container->get('doctrine.connection.orm_default');
    ```

Example configure container
---------------------------

[](#example-configure-container)

> Laminas ServiceManager

```
use Streamcommon\Doctrine\Manager\ConfigProvider;
use Laminas\ServiceManager\ServiceManager;

$config = new ConfigProvider();
$config = $config();
$dependencies = $config['dependencies'];
$dependencies['services']['config'] = $config;
return new ServiceManager($dependencies);
```

> Symfony Container

```
use JSoumelidis\SymfonyDI\Config\{Config as SymfonyConfig, ContainerFactory as SymfonyContainerFactory};
use Streamcommon\Doctrine\Manager\ConfigProvider;

$config = new ConfigProvider();
$config = $config();
$dependencies = $config['dependencies'];
$dependencies['services']['config'] = $config;
$container = new SymfonyContainerFactory();
return $container(new SymfonyConfig($dependencies))
```

> Etc...

CLI usage
---------

[](#cli-usage)

1. See
    - [doctrine orm console tools](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/tools.html)
    - [doctrine migrations console tools](https://www.doctrine-project.org/projects/doctrine-migrations/en/2.1/reference/introduction.html#introduction)
2. For many connections was added a new `--object-manager` argument to `orm` namespace:

```
Arguments:
  --object-manager      Doctrine object manager name [default: "orm_default"]
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 98.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~63 days

Recently: every ~69 days

Total

20

Last Release

1434d ago

PHP version history (3 changes)1.0.0PHP ^7.2

1.1.5PHP ^7.3

1.2.4.5PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a435df1458c75a1a9760f611d3ba8058b3b6781ce55d3893249cb3fefd644ea?d=identicon)[streamcommon](/maintainers/streamcommon)

---

Top Contributors

[![aleksandr-yulin](https://avatars.githubusercontent.com/u/5064134?v=4)](https://github.com/aleksandr-yulin "aleksandr-yulin (76 commits)")[![Colomix](https://avatars.githubusercontent.com/u/17410674?v=4)](https://github.com/Colomix "Colomix (1 commits)")

---

Tags

doctrinephp-componentphp7psr-11PSR-11streamcommondoctrine containerdoctrine clidoctrine zend servicemanagerdoctrine auradidoctrine pimpledoctrine symfony containerdoctrine managerdoctrine laminas servicemanager

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/streamcommon-doctrine-manager/health.svg)

```
[![Health](https://phpackages.com/badges/streamcommon-doctrine-manager/health.svg)](https://phpackages.com/packages/streamcommon-doctrine-manager)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M648](/packages/sylius-sylius)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M35](/packages/scienta-doctrine-json-functions)[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M292](/packages/doctrine-doctrine-orm-module)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[neos/flow

Flow Application Framework

862.0M450](/packages/neos-flow)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
