PHPackages                             sinsquare/silex-doctrine-orm-provider - 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. sinsquare/silex-doctrine-orm-provider

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

sinsquare/silex-doctrine-orm-provider
=====================================

Doctrine ORM provider for Silex framework

v1.0.7(8y ago)11.5kMITPHPPHP ~5.6|~7.0

Since Jul 3Pushed 8y ago2 watchersCompare

[ Source](https://github.com/SinSquare/silex-doctrine-orm-provider)[ Packagist](https://packagist.org/packages/sinsquare/silex-doctrine-orm-provider)[ RSS](/packages/sinsquare-silex-doctrine-orm-provider/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (8)Versions (9)Used By (0)

Doctrine ORM provider for Silex 2.x framework
=============================================

[](#doctrine-orm-provider-for-silex-2x-framework)

Code qualityTestsIssues[![SensioLabsInsight](https://camo.githubusercontent.com/3afffc0a02a3ce5517206ef4d91331ecd2d33639467dae46b234c3fda1c38413/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f37333038373535382d323435662d343539382d383236612d3330653234613033653838302f6269672e706e67)](https://insight.sensiolabs.com/projects/73087558-245f-4598-826a-30e24a03e880)[![Build Status](https://camo.githubusercontent.com/dae96c57626eefaf2d912e8fbbe024dde603985795b2779a1b87e9c618c4b0c1/68747470733a2f2f7472617669732d63692e6f72672f53696e5371756172652f73696c65782d646f637472696e652d6f726d2d70726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/SinSquare/silex-doctrine-orm-provider)[![Issue Count](https://camo.githubusercontent.com/0f08e0e2032884ec89e257113526ffc38577ac340b6deb9e5a8c78d9d7302560/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f53696e5371756172652f73696c65782d646f637472696e652d6f726d2d70726f76696465722f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/SinSquare/silex-doctrine-orm-provider/issues)[![Codacy Badge](https://camo.githubusercontent.com/e6983fdc9cf5c17b1ef4bbfbde40738d581a1d244219bf8a2e82ff582db30f4d/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3964323464396130316339393461356539343063646636346465666138636635)](https://www.codacy.com/app/SinSquare/silex-doctrine-orm-provider?utm_source=github.com&utm_medium=referral&utm_content=SinSquare/silex-doctrine-orm-provider&utm_campaign=Badge_Grade)[![Test Coverage](https://camo.githubusercontent.com/a2a0cb4a05270ddece5fd80458005066038336bef68f4c590c8689e064d54bf1/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f53696e5371756172652f73696c65782d646f637472696e652d6f726d2d70726f76696465722f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/SinSquare/silex-doctrine-orm-provider/coverage)[![Code Climate](https://camo.githubusercontent.com/b2d91e62ef2c748862ee51c7110644e1ed123765de4d0d6b6760492229db67e6/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f53696e5371756172652f73696c65782d646f637472696e652d6f726d2d70726f76696465722f6261646765732f6770612e737667)](https://codeclimate.com/github/SinSquare/silex-doctrine-orm-provider)Installation
============

[](#installation)

With composer :

```
{
    "require": {
        "sinsquare/silex-doctrine-orm-provider": "1.*"
    }
}
```

Registering the providers
=========================

[](#registering-the-providers)

- If you only need the ORM without validation and web profiler

```
use Silex\Provider\DoctrineServiceProvider;
use SinSquare\Cache\DoctrineCacheServiceProvider;
use SinSquare\Doctrine\DoctrineOrmServiceProvider;

...

$application['doctrine.orm.options'] = array();

$application->register(new DoctrineServiceProvider());
$application->register(new DoctrineCacheServiceProvider());
$application->register(new DoctrineOrmServiceProvider());
```

- If you only need the ORM validation (UniqueEntity)

```
//Register all the providers for the ORM

use Silex\Provider\ValidatorServiceProvider;
use SinSquare\Doctrine\DoctrineOrmValidatorProvider;

...

$application->register(new ValidatorServiceProvider());
$application->register(new DoctrineOrmValidatorProvider());
```

- If you only need the the ORM web profiler

```
//Register all the providers for the ORM

use SinSquare\Doctrine\DoctrineOrmWebProfilerProvider;

...

$application->register(new DoctrineOrmWebProfilerProvider());
```

Configuration
=============

[](#configuration)

The configuration of the ORM must be set in $application\['doctrine.orm.options'\], and it must exist before registering the provider.

A basic configuration scheme:

```
$application['doctrine.orm.options'] = array(
    'default_entity_manager' => 'default',
    'auto_generate_proxy_classes' => true,
    'proxy_dir' => __DIR__.'/Resources/Proxy',
    'proxy_namespace' => 'Proxies',

    'entity_managers' => array(
        'default' => array(
            'query_cache_driver' => array(
                'type' => 'array',
            ),
            'metadata_cache_driver' => array(
                'type' => 'array',
            ),
            'result_cache_driver' => array(
                'type' => 'array',
            ),
            'connection' => 'db1',
            'mappings' => array(
                array(
                    'type' => 'annotation',
                    'namespace' => 'SinSquare\\Doctrine\\Tests\\Resources\\Entity',
                    'alias' => 'TestBundle',
                    'path' => __DIR__.'/Resources/Entity',
                    'use_simple_annotation_reader' => false,
                ),
            ),
        ),
    ),
);
```

The configuration scheme is similar to the one used in Smyfony [(read more here)](https://symfony.com/doc/current/reference/configuration/doctrine.html).

- default\_entity\_manager: Name of the default entity manager. If not set the first one will be the default.
- connection: Name of the DBAL connection to use. Read more at the DoctrineServiceProvider help [here](https://silex.sensiolabs.org/doc/2.0/providers/doctrine.html).
- mapping: Currently only the annotation type is supported by default, but you can extend the functionality. Look for $app\['doctrine.orm.mappingdriver.locator'\] in the DoctrineOrmServiceProvider.
- cache: The project uses SinSquare/silex-doctrine-orm-provider for cacheing, which is a wrapper for Doctrine Cache.

- Using anonym cache:

```
'query_cache_driver' => array(
    'type' => 'array',
),
```

You can change the cache type, for more info check the Doctrine Cache component. \*Using named cache:

```
$application['doctrine.cache.options'] = array(
    'providers' => array(
        'cache_1' => array(
            'type' => 'void',
        )
    ),
);

$application['doctrine.orm.options'] = array(
    ...
    'result_cache_driver' => array(
        'name' => 'cache_1',
    ),
    ...
);
```

You can create new types of caches, please read how to [here](https://github.com/SinSquare/silex-doctrine-orm-provider);

Retrieving the EntityManager
============================

[](#retrieving-the-entitymanager)

- The default entity manager:

```
$em = $application['doctrine.orm.em'];
```

- A named entity manager:

```
$em = $application['doctrine.orm.ems']['named_em'];
//OR
$em = $application['doctrine.orm.em.named_em'];
```

Using the validator
===================

[](#using-the-validator)

```
    $entity = new Entity();

    //modify the entity

    $validator = $application['validator'];
    $errors = $validator->validate($entity);
    if(count($errors)) {
        //there was an error
    }
```

Adding custom subscribers to the EntityManager
==============================================

[](#adding-custom-subscribers-to-the-entitymanager)

If you need to attach subscriber to the EntityManager you should use the $application\['doctrine.orm.em\_factory.postinit'\] as it runs only once after the fist call on the manager.

```
$application['doctrine.orm.em_factory.postinit'] = $this->application->protect(function ($name, $options, $manager) use ($application) {

    $eventManager = $manager->getEventManager();
    $eventManager->addEventSubscriber($subscriber);

    return $manager;
});
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~4 days

Total

8

Last Release

3208d ago

PHP version history (2 changes)v1.0PHP ~5.4|~7.0

v1.0.2PHP ~5.6|~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/88583e063973f17c93b1aa30054cd843d58fbacaaa566ac2b4b2ed9ea903cffd?d=identicon)[SinSquare](/maintainers/SinSquare)

---

Top Contributors

[![SinSquare](https://avatars.githubusercontent.com/u/7294724?v=4)](https://github.com/SinSquare "SinSquare (3 commits)")[![name12](https://avatars.githubusercontent.com/u/3661459?v=4)](https://github.com/name12 "name12 (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/sinsquare-silex-doctrine-orm-provider/health.svg)

```
[![Health](https://phpackages.com/badges/sinsquare-silex-doctrine-orm-provider/health.svg)](https://phpackages.com/packages/sinsquare-silex-doctrine-orm-provider)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

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

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)

PHPackages © 2026

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