PHPackages                             locky42/leopard-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. locky42/leopard-doctrine

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

locky42/leopard-doctrine
========================

Lightweight PHP framework for working with databases using the Doctrine ORM.

1.1.1(1mo ago)0122MITPHPPHP ^8.3

Since Oct 23Pushed 1mo agoCompare

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

READMEChangelog (3)Dependencies (4)Versions (4)Used By (2)

Leopard Doctrine
================

[](#leopard-doctrine)

`locky42/leopard-doctrine` integrates Doctrine ORM with Leopard events and provides a registry for `ResolveTargetEntity` mappings.

Features
--------

[](#features)

- Global wrapper around Doctrine `EntityManager` (`Leopard\Doctrine\EntityManager`)
- `ResolveTargetEntityRegistry` for interface → implementation mappings
- Event-based initialization hooks:
    - `BeforeInitEventManagerEvent`
    - `AfterInitEventManagerEvent`
    - `BeforeInitEntityManagerEvent`
    - `AfterInitEntityManagerEvent`

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

[](#installation)

```
composer require locky42/leopard-doctrine
```

Usage
-----

[](#usage)

### 1) Configure mappings (optional)

[](#1-configure-mappings-optional)

Register interface mappings before `BeforeInitEntityManagerEvent` is dispatched:

```
use Leopard\Doctrine\ResolveTargetEntityRegistry;
use Leopard\User\Contracts\Models\UserInterface;
use App\Models\User;

ResolveTargetEntityRegistry::addResolveTargetEntity(
    UserInterface::class,
    User::class,
    []
);
```

### 2) Initialize Doctrine and Leopard events

[](#2-initialize-doctrine-and-leopard-events)

```
use Doctrine\Common\EventManager as DoctrineEventManager;
use Doctrine\DBAL\DriverManager;
use Doctrine\ORM\EntityManager as ORMEntityManager;
use Doctrine\ORM\ORMSetup;
use Leopard\Doctrine\EntityManager;
use Leopard\Doctrine\Events\BeforeInitEntityManagerEvent;
use Leopard\Doctrine\Events\BeforeInitEventManagerEvent;
use Leopard\Doctrine\Events\AfterInitEventManagerEvent;
use Leopard\Events\EventManager as LeopardEventManager;

$config = ORMSetup::createAttributeMetadataConfiguration(
    paths: [__DIR__ . '/src/Models'],
    isDevMode: true
);

LeopardEventManager::doEvent(BeforeInitEventManagerEvent::class);

$eventManager = new DoctrineEventManager();

LeopardEventManager::doEvent(AfterInitEventManagerEvent::class, $eventManager);

$connection = DriverManager::getConnection([
    // driver, host, dbname, user, password...
], null, $eventManager);

LeopardEventManager::doEvent(BeforeInitEntityManagerEvent::class);

// Important: pass the same Doctrine EventManager to ORM EntityManager
$ormEntityManager = new ORMEntityManager($connection, $config, $eventManager);

EntityManager::setEntityManager($ormEntityManager);
```

### 3) Retrieve EntityManager anywhere

[](#3-retrieve-entitymanager-anywhere)

```
$em = EntityManager::getEntityManager();
```

Requirements
------------

[](#requirements)

- PHP 8.3+
- Doctrine ORM 3.x
- `locky42/leopard-events`

Notes
-----

[](#notes)

- If you use `ResolveTargetEntity`, ensure listeners are attached to the same Doctrine `EventManager` instance that is passed to ORM `EntityManager`.
- The package bootstrap auto-registers internal listeners via Composer autoload files.

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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

Every ~73 days

Total

3

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72bf088ea009ca7340ddb130d80d71a31ad8726ab71133a176e38326600696bb?d=identicon)[locky42](/maintainers/locky42)

---

Top Contributors

[![locky42](https://avatars.githubusercontent.com/u/57048956?v=4)](https://github.com/locky42 "locky42 (11 commits)")

### Embed Badge

![Health badge](/badges/locky42-leopard-doctrine/health.svg)

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

###  Alternatives

[scienta/doctrine-json-functions

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

58523.9M35](/packages/scienta-doctrine-json-functions)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[pixelfederation/doctrine-resettable-em-bundle

Symfony bundle for decorating default entity managers using a resettable decorator.

20113.5k](/packages/pixelfederation-doctrine-resettable-em-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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