PHPackages                             api-skeletons/zf-doctrine-repository - 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. api-skeletons/zf-doctrine-repository

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

api-skeletons/zf-doctrine-repository
====================================

Plugin Architecture for Doctrine Repositories

1.0.3(8y ago)178612MITPHPPHP ^7.1

Since Jul 9Pushed 8y ago2 watchersCompare

[ Source](https://github.com/API-Skeletons/zf-doctrine-repository)[ Packagist](https://packagist.org/packages/api-skeletons/zf-doctrine-repository)[ RSS](/packages/api-skeletons-zf-doctrine-repository/feed)WikiDiscussions master Synced 4d ago

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

zf-doctrine-repository
======================

[](#zf-doctrine-repository)

[![Build Status](https://camo.githubusercontent.com/27406ef16b66ff5c105a440337efde08b75335af1708b843aadeec8aa72c5de9/68747470733a2f2f7472617669732d63692e6f72672f4150492d536b656c65746f6e732f7a662d646f637472696e652d7265706f7369746f72792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/API-Skeletons/zf-doctrine-repository)[![Gitter](https://camo.githubusercontent.com/c45f0485e89d3cd41f666d7d4bb5875cb59836555e05b6b11f77ed223eb64c0c/68747470733a2f2f6261646765732e6769747465722e696d2f6170692d736b656c65746f6e732f6f70656e2d736f757263652e737667)](https://gitter.im/api-skeletons/open-source)[![Total Downloads](https://camo.githubusercontent.com/be8fe5ab7461e48482094cb5b0e46f68bf27c29bcc75608fe44119f76a3cf13e/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f7a662d646f637472696e652d7265706f7369746f72792f646f776e6c6f616473)](https://packagist.org/packages/api-skeletons/zf-doctrine-repository)

This is a replacement for the default repository structure of Doctrine ORM. This replacement implements a plugin architecture for extensisons to repositories.

For instance, if you need access to an encryption/decryption resource inside your repository you could implement it as a plugin accessible as

```
$this->plugin('encryption')->encrypt($value);
```

Why use this repository structure?
----------------------------------

[](#why-use-this-repository-structure)

The default repository for Doctrine ORM gives no access to resources outside Doctrine. And the Doctrine ORM Object Manager does not give access to a dependency injection container. So when your applications require more from their repositories the only option is to write your own dependency injection enabled repository factory. To create a standard way to organize this dependency injection repository factory: this is an acceptable solution.

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

[](#installation)

Installation of this module uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

```
$ composer require api-skeletons/zf-doctrine-repository
```

Once installed, add `ZF\Doctrine\Repository` to your list of modules inside `config/application.config.php` or `config/modules.config.php`.

> ### zf-component-installer
>
> [](#zf-component-installer)
>
> If you use [zf-component-installer](https://github.com/zendframework/zf-component-installer), that plugin will install zf-doctrine-repository as a module for you.

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

[](#configuration)

No manual configuration is required to use this module.

This module makes these changes to your `doctrine.entitymanager.orm_default` configuration:

```
namespace ZF\Doctrine\Repository;
...
    'doctrine' => [
        'configuration' => [
            'orm_default' => [
                'repository_factory' => RepositoryFactory::class,
                'default_repository_class_name' => ObjectRepository::class,
            ],
        ],
    ],

```

If your application already has a default repository class you can edit it to implement `ZF\Doctrine\Repository\ObjectRepositoryInterface` and the RepositoryFactory can use it.

Creating a Plugin
-----------------

[](#creating-a-plugin)

The config key for the repository plugin service locator is `zf-doctrine-repository-plugin`. Your plugin must implement `ZF\Doctrine\Repository\Plugin\PluginInterface`

The `__construct` of your Plugin will take an array including the repository and any other parameters. Access to the repository gives you access to the ObjectManager.

Use the [testing boolean plugin](https://github.com/API-Skeletons/zf-doctrine-repository/blob/master/test/asset/module/Doctrine/src/Plugin/BooleanPlugin.php)and [testing boolean plugin configuration](https://github.com/API-Skeletons/zf-doctrine-repository/blob/master/test/asset/module/Doctrine/config/module.config.php)as a template.

Available Plugins
-----------------

[](#available-plugins)

**[zf-doctrine-repository-query-provider](https://github.com/api-skeletons/zf-doctrine-repository-query-provider)** - [zfcampus/zf-apigility-doctrine](https://github.com/zfcampus/zf-apigiltiy-doctrine)includes Query Providers which may take the current authenticated user and add complex filters to a a QueryBuilder object in order to filter whether the user has access to a given entity. This filtering mechanism can be used across a whole application whenever authorized access is needed to an entity.

```
use Database\Entity\User;

// Return a single User entity fetched by applying the User Query Provider to a given `$id`
$objectManager->getRepository(User::class)->plugin('queryProvider')->find($id);

```

Future Plugin Plans
-------------------

[](#future-plugin-plans)

This repository is forward-looking and architected to support the needs today and into the future. Here are examples of repository plugins to be developed:

**zf-doctrine-repository-audit** - A trigger-happy application will create a structure of triggers on all tables accessible as Doctrine entities. Data would be accessible directly or to access the audit data with a plugin:

```
use Database\Entity\User;

// Return the date an entity was created using the audit trail.
$objectManager->getRepository(User::class)->plugin('audit')->getCreatedAt(User $userEntity);

// Return the date an entity was last modified using the audit trail.
$objectManager->getRepository(User::class)->plugin('audit')->getUpdatedAt(User $userEntity);

// Return the complete audit trail for an entity
$objectManager->getRepository(User::class)->plugin('audit')->getAuditTrail(User $userEntity);

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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 ~90 days

Total

4

Last Release

2963d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49dd7d9dba889ac674b0da447d9c1e69d1128dc3ccbaef98ba83d6ee519fc2d6?d=identicon)[tom\_anderson](/maintainers/tom_anderson)

---

Top Contributors

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

---

Tags

doctrine-orm

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/api-skeletons-zf-doctrine-repository/health.svg)

```
[![Health](https://phpackages.com/badges/api-skeletons-zf-doctrine-repository/health.svg)](https://phpackages.com/packages/api-skeletons-zf-doctrine-repository)
```

###  Alternatives

[zf-commons/zfc-user-doctrine-orm

Doctrine2 ORM storage adapter for ZfcUser.

85676.8k18](/packages/zf-commons-zfc-user-doctrine-orm)[hounddog/doctrine-data-fixture-module

Zend Framework 2 Module that provides Doctrine Data-Fixture functionality

37335.4k9](/packages/hounddog-doctrine-data-fixture-module)[mamuz/mamuz-blog

Provides blog feature for ZF2 with Doctrine

101.1k1](/packages/mamuz-mamuz-blog)

PHPackages © 2026

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