PHPackages                             bentools/doctrine-static - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bentools/doctrine-static

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bentools/doctrine-static
========================

Doctrine Static - Mock managers and repositories in simple arrays, without any database.

21.5k3PHP

Since Apr 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/bpolaszek/doctrine-static)[ Packagist](https://packagist.org/packages/bentools/doctrine-static)[ RSS](/packages/bentools-doctrine-static/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (4)Used By (3)

Doctrine Static
===============

[](#doctrine-static)

This library is intended to be used for mocking ObjectManagers and Repositories behaviors in your unit tests.

It is of course not intended to be used as a real persistence system.

Main features
-------------

[](#main-features)

- Create different `ObjectManager` and store them in a `ManagerRegistry`
- Use `$objectManager->persist()`, `$objectManager->remove()` and `$objectManager->flush()` as usual (objects are stored in a temporary array before you call `flush()`)
- Use repository methods like `find()`, `findBy()`, `findOneBy()` and `findAll()`

Unsupported features
--------------------

[](#unsupported-features)

- Everything UnitofWork-related
- Class metadata
- `merge`, `detach`, `refresh`, ...

Example usage
-------------

[](#example-usage)

```
namespace App\Entity;

class Foo
{

    private $id;
    private $name;

    /**
     * Foo constructor.
     * @param $id
     * @param $name
     */
    public function __construct($id, $name)
    {
        $this->id = $id;
        $this->name = $name;
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }

}
```

```
use App\Entity\Foo;
use BenTools\DoctrineStatic\ManagerRegistry;
use BenTools\DoctrineStatic\ObjectManager;
use BenTools\DoctrineStatic\ObjectRepository;

require_once __DIR__ . '/vendor/autoload.php';

$foo = new Foo(2, 'foo');

$doctrine = new ManagerRegistry([
    'default' => new ObjectManager([
            new ObjectRepository(Foo::class)
        ]
    ),
]);

$em = $doctrine->getManager();
$em->persist($foo);
$em->flush();

// Retrieve object by id
$em->find(Foo::class, 2);

// Retrieve objects with name matching "foo"
$em->getRepository(Foo::class)->findBy(['name' => 'foo']);
```

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

[](#installation)

> composer require --dev benools/doctrine-static:1.0.x-dev

Tests
-----

[](#tests)

> ./vendor/bin/phpunit

License
-------

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/acdd1a8ee0e657ddd06cf11f98a32100ef7121afb8aa270a5b295f5c29c038b3?d=identicon)[bpolaszek](/maintainers/bpolaszek)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/bentools-doctrine-static/health.svg)

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

###  Alternatives

[vimeo/ablincoln

PHP library for designing online experiments

153301.5k](/packages/vimeo-ablincoln)

PHPackages © 2026

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