PHPackages                             68publishers/doctrine-bridge - 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. 68publishers/doctrine-bridge

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

68publishers/doctrine-bridge
============================

Bridges between integrations of Doctrine ORM and '68publishers bundles.

v1.1.0(2y ago)03.6k↓47.5%5MITPHPPHP ^8.1

Since Nov 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/68publishers/doctrine-bridge)[ Packagist](https://packagist.org/packages/68publishers/doctrine-bridge)[ RSS](/packages/68publishers-doctrine-bridge/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (10)Versions (8)Used By (5)

Doctrine bridge
===============

[](#doctrine-bridge)

Register custom DBAL types, entity mappings, target entities and migration directories directly inside your CompilerExtensions!

[![Checks](https://camo.githubusercontent.com/382f40fd084bc842fac967a15c4974c59eea15091ac55d941800c9d715bc2ef9/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f36387075626c6973686572732f646f637472696e652d6272696467652f6d6173746572)](https://github.com/68publishers/doctrine-bridge/actions)[![Coverage Status](https://camo.githubusercontent.com/f3124c220a207c24f178c3c2ac79fe30285178bb865db2a9383335374bbac6d2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f36387075626c6973686572732f646f637472696e652d6272696467652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/68publishers/doctrine-bridge?branch=master)[![Total Downloads](https://camo.githubusercontent.com/a643e56793177ed4ccfb2c75d35170c21300c13aedca63ed2cc2a9e6096b0165/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f36387075626c6973686572732f646f637472696e652d627269646765)](https://packagist.org/packages/68publishers/doctrine-bridge)[![Latest Version](https://camo.githubusercontent.com/e349cad0947cf91ff38dc57b1cf59f54726306a6acc946da81c1bf568a121346/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f36387075626c6973686572732f646f637472696e652d627269646765)](https://packagist.org/packages/68publishers/doctrine-bridge)[![PHP Version](https://camo.githubusercontent.com/fbd0737b79f4bc2b2e302dfb9279c849752a4a848e0484840093b936b831f4ae/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f36387075626c6973686572732f646f637472696e652d627269646765)](https://packagist.org/packages/68publishers/doctrine-bridge)

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

[](#installation)

The best way to install 68publishers/doctrine-bridge is using Composer:

```
$ composer require 68publishers/doctrine-bridge
```

Configuration
-------------

[](#configuration)

```
extensions:
    68publishers.doctrine_bridge: SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\DoctrineBridgeExtension

# The default configuration:
68publishers.doctrine_bridge:
    database_types_enabled: yes # Enables/disables registration of acustom DBAL types
    entity_mappings_enabled: yes # Enables/disables registration of entity mappings
    target_entities_enabled: yes # Enables/disables resolving of target entities
    migration_directories_enabled: yes # Enables/disables registration of migrations for doctrine/migrations

    # Dependent services. Allowed are classname strings (for autowired services) or references e.g. @myService
    services:
        dbal_connection: Doctrine\DBAL\Connection
        drivers:
            # For drivers, you can use `false`. In this case, mappings for the drive will be omitted
            chain: Doctrine\Persistence\Mapping\Driver\MappingDriverChain
            annotation: Doctrine\ORM\Mapping\Driver\AnnotationDriver
            xml: Doctrine\ORM\Mapping\Driver\XmlDriver
            simplified_xml: Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver
            attribute: Doctrine\ORM\Mapping\Driver\AttributeDriver
        migrations_configuration: Doctrine\Migrations\Configuration\Configuration
```

The package is fully tested in combination with [nettrine/orm](https://github.com/contributte/doctrine-orm) and [nettrine/migrations](https://github.com/contributte/doctrine-migrations), however it can be plugged into almost any Doctrine integration into the Nette Framework using the `services` options.

Usage
-----

[](#usage)

### Database Type Provider

[](#database-type-provider)

```
use Doctrine\DBAL\Types\Types;
use Nette\DI\CompilerExtension;
use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\DatabaseType;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\DatabaseTypeProviderInterface;

class MyExtension extends CompilerExtension implements DatabaseTypeProviderInterface
{
    public function getDatabaseTypes() : array
    {
        return [
            new DatabaseType('uuid_binary_ordered_time', Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType::class, Types::BINARY),
            new DatabaseType('my_custom_type', MyCustomType::class),
        ];
    }
}
```

#### Services in Doctrine Types

[](#services-in-doctrine-types)

Doctrine DBAL types don't have access to services by default. With this extension, you can receive the DI Container in custom types when the Connection is created.

```
use Nette\DI\Container;
use Doctrine\DBAL\Types\StringType;
use SixtyEightPublishers\DoctrineBridge\Type\ContainerAwareTypeInterface;

final class MyExtension extends StringType implements ContainerAwareTypeInterface
{
    private MyService $service;

    public function setContainer(Container $container, array $context = []) : void
    {
        $this->service = $container->getByType(MyService::class);
    }
}
```

#### Registering Doctrine Types via bundled DatabaseTypeProviderExtension

[](#registering-doctrine-types-via-bundled-databasetypeproviderextension)

To register custom types, it is not necessary to create a custom extension, but the class `DatabaseTypeProviderExtension` can be used.

```
extensions:
    68publishers.doctrine_bridge.database_type_provider: SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\DatabaseTypeProviderExtension

68publishers.doctrine_bridge.database_type_provider:
    # inline notation:
    my_type_1: App\DbalType\MyType1

    # structured notation:
    my_type_2:
        class: App\DbalType\MyType2
        mapping_type: text
        context: []
```

### Entity Mapping Provider

[](#entity-mapping-provider)

```
use Nette\DI\CompilerExtension;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\EntityMapping;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\EntityMappingProviderInterface;

class MyExtension extends CompilerExtension implements EntityMappingProviderInterface
{
    public function getEntityMappings() : array
    {
        return [
            new EntityMapping(EntityMapping::DRIVER_ANNOTATION, 'App\\Entity', __DIR__ . '/../Entity'),
            new EntityMapping(EntityMapping::DRIVER_ATTRIBUTE, 'App\\Entity', __DIR__ . '/../Entity'),
            new EntityMapping(EntityMapping::DRIVER_XML, 'App\\Entity', __DIR__ . '/../Mapping/xml'),
            # or
            new EntityMapping(EntityMapping::DRIVER_SIMPLIFIED_XML, 'App\\Entity', __DIR__ . '/../Mapping/xml'),
        ];
    }
}
```

### Target Entity Provider

[](#target-entity-provider)

```
use Nette\DI\CompilerExtension;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\TargetEntity;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\TargetEntityProviderInterface;

class MyExtension extends CompilerExtension implements TargetEntityProviderInterface
{
    public function getTargetEntities() : array
    {
        return [
            new TargetEntity(ProductInterface::class, ProductEntity::class),
        ];
    }
}
```

### Migration directories

[](#migration-directories)

```
use Nette\DI\CompilerExtension;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\TargetEntity;
use SixtyEightPublishers\DoctrineBridge\Bridge\Nette\DI\MigrationsDirectoriesProviderInterface;

class MyExtension extends CompilerExtension implements MigrationsDirectoriesProviderInterface
{
    public function getMigrationsDirectories() : array
    {
        return [
            new MigrationsDirectory('App\\Bundle\\MyBundle\\Migrations', __DIR__ . '/../Migrations'),
        ];
    }
}
```

Contributing
------------

[](#contributing)

Before opening a pull request, please check your changes using the following commands

```
$ make init # to pull and start all docker images

$ make cs.check
$ make stan
$ make tests.all
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 84.6% 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 ~165 days

Recently: every ~122 days

Total

7

Last Release

1002d ago

Major Versions

v0.2.1 → v1.0.02022-12-16

PHP version history (4 changes)v0.1PHP ^7.3

v0.1.2PHP ^7.4

v0.2.0PHP ^7.4 || ^8.0

v1.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/609005caba54757716c3c037c381376ab298714003da87c9e20aa8c501c97df8?d=identicon)[Jelen](/maintainers/Jelen)

---

Top Contributors

[![tg666](https://avatars.githubusercontent.com/u/24430186?v=4)](https://github.com/tg666 "tg666 (11 commits)")[![jelen07](https://avatars.githubusercontent.com/u/2346295?v=4)](https://github.com/jelen07 "jelen07 (2 commits)")

---

Tags

bridgebundledoctrineextensionnettenette-extensionormnetteormdoctrineBridge68publishers

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/68publishers-doctrine-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/68publishers-doctrine-bridge/health.svg)](https://phpackages.com/packages/68publishers-doctrine-bridge)
```

###  Alternatives

[scienta/doctrine-json-functions

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

58723.9M36](/packages/scienta-doctrine-json-functions)[kdyby/doctrine

Doctrine integration into Nette Framework

1091.0M86](/packages/kdyby-doctrine)[nettrine/orm

Doctrine ORM for Nette Framework

581.9M37](/packages/nettrine-orm)[nettrine/extensions-atlantic18

Doctrine2 behavioral extensions for Nette Framework

12922.2k3](/packages/nettrine-extensions-atlantic18)[majkl578/nette-identity-doctrine

Integration of entities implementing IIdentity in Nette 2

28119.1k](/packages/majkl578-nette-identity-doctrine)

PHPackages © 2026

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