PHPackages                             klsoft/yii3-doctrine - 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. klsoft/yii3-doctrine

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

klsoft/yii3-doctrine
====================

The package provides an easy way to integrate the Yii 3 framework with the Doctrine ORM

1.0.0(2mo ago)029↓75%5MITPHP

Since Mar 17Pushed 2mo agoCompare

[ Source](https://github.com/klsoft-web/yii3-doctrine)[ Packagist](https://packagist.org/packages/klsoft/yii3-doctrine)[ Docs](https://github.com/klsoft-web/yii3-doctrine)[ RSS](/packages/klsoft-yii3-doctrine/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (5)

YII3-DOCTRINE
=============

[](#yii3-doctrine)

The package provides an easy way to integrate the [Yii 3 framework](https://yii3.yiiframework.com) with the [Doctrine ORM](https://www.doctrine-project.org/).

See also:

- [YII3-CACHE-DOCTRINE](https://github.com/klsoft-web/yii3-cache-doctrine) - The package provides the [PSR-16](https://www.php-fig.org/psr/psr-16/) cache using the [Doctrine ORM](https://www.doctrine-project.org/)
- [YII3-RBAC-DOCTRINE](https://github.com/klsoft-web/yii3-rbac-doctrine) - The package provides [Yii RBAC](https://github.com/yiisoft/rbac) storage using the [Doctrine ORM](https://www.doctrine-project.org/)
- [YII3-DATAREADER-DOCTRINE](https://github.com/klsoft-web/yii3-datareader-doctrine) - The package provides a [Yii 3 data reader](https://github.com/yiisoft/data?tab=readme-ov-file#reading-data) that uses the [Doctrine ORM](https://www.doctrine-project.org/)
- [YII3-DOCTRINE-APP](https://github.com/klsoft-web/yii3-doctrine-app) - [Yii 3](https://yii3.yiiframework.com) web application template that supports [Doctrine ORM](https://www.doctrine-project.org/)

Requirement
-----------

[](#requirement)

- PHP 8.2 or higher.

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

[](#installation)

```
composer require klsoft/yii3-doctrine
```

How to use
----------

[](#how-to-use)

### 1. Configure the EntityManagerInterface.

[](#1-configure-the-entitymanagerinterface)

Add the Doctrine parameters to the `config/common/params.php`:

```
return [
    // ...
    'doctrine' => [
        'paths' =>  [__DIR__ . '/../../src/Data/Entities'],
        'isDevMode' => true,
        'connection' => [
            'driver'   => 'pdo_mysql',
            'user'     => 'mydb',
            'password' => 'secret',
            'dbname'   => 'mydb',
        ]
    ],
];
```

Register the Doctrine dependencies in the `config/common/di/application.php`:

```
use Doctrine\ORM\ORMSetup;
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\EntityManagerProvider;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
use Psr\Container\ContainerInterface;

return [
    // ...
    Configuration::class => ORMSetup::createAttributeMetadataConfiguration(
        paths: $params['doctrine']['paths'],
        isDevMode: $params['doctrine']['isDevMode']
    ),
    EntityManagerInterface::class => static function (ContainerInterface $container) use ($params) {
        $configuration = $container->get(Configuration::class);
        return new EntityManager(
            DriverManager::getConnection(
                $params['doctrine']['connection'],
                $configuration
            ),
            $configuration);
    },
    EntityManagerProvider::class => SingleManagerProvider::class,
];
```

### 2. Run the Doctrine console command.

[](#2-run-the-doctrine-console-command)

Example:

```
APP_ENV=dev ./yii doctrine:orm:schema-tool:create
```

The following commands are currently available:

- doctrine:orm:schema-tool:create
- doctrine:orm:schema-tool:drop
- doctrine:orm:schema-tool:update
- doctrine:orm:clear-cache:metadata
- doctrine:orm:validate-schema
- doctrine:orm:mapping-describe
- doctrine:orm:run-dql
- doctrine:orm:info
- doctrine:orm:generate-proxies
- doctrine:orm:clear-cache:query
- doctrine:orm:clear-cache:result
- doctrine:dbal:run-sql

### 3. Inject the EntityManagerInterface.

[](#3-inject-the-entitymanagerinterface)

Example:

```
use Doctrine\ORM\EntityManagerInterface;

final class ProductRepository implements ProductRepositoryInterface
{
    public function __construct(private EntityManagerInterface $entityManager)
    {
    }
}
```

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance85

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

63d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f4e8ac50e4ad22be84b07f4c06d28cf280d22f689c460cd385c556727e638827?d=identicon)[klsoft-web](/maintainers/klsoft-web)

---

Top Contributors

[![klsoft-web](https://avatars.githubusercontent.com/u/7967163?v=4)](https://github.com/klsoft-web "klsoft-web (2 commits)")

---

Tags

ormdoctrineyii3

### Embed Badge

![Health badge](/badges/klsoft-yii3-doctrine/health.svg)

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

###  Alternatives

[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8425.3M87](/packages/laravel-doctrine-orm)[scienta/doctrine-json-functions

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

58723.9M36](/packages/scienta-doctrine-json-functions)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

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

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[data-dog/audit-bundle

Audit bundle for symfony2 and doctrine orm, logs any database change

141901.7k1](/packages/data-dog-audit-bundle)

PHPackages © 2026

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