PHPackages                             webgriffe/in-memory-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. webgriffe/in-memory-repository

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

webgriffe/in-memory-repository
==============================

A Doctrine repository implementation with in-memory storage.

0.4.0(6mo ago)0781↑41.2%MITPHPPHP ^8.2CI passing

Since Jan 31Pushed 6mo ago5 watchersCompare

[ Source](https://github.com/webgriffe/in-memory-repository)[ Packagist](https://packagist.org/packages/webgriffe/in-memory-repository)[ RSS](/packages/webgriffe-in-memory-repository/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (7)Versions (5)Used By (0)

Doctrine "in-memory" Repository
===============================

[](#doctrine-in-memory-repository)

This library is an "in-memory" implementation of the `Doctrine\Persistence\ObjectRepository` interface. It can be used to unit test components which depends on Doctrine repositories without involving a real database.

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

[](#installation)

Add it to your "dev" dependencies:

```
composer require --dev webgriffe/in-memory-repository
```

Usage
-----

[](#usage)

Let's assume that you're building a movie management application and you have a Doctrine's `MovieRepository` (which implements a `MovieRepositoryInterface`) that's used by your services to fetch movies from database in your application.

Now let's say that to unit test those services which depends on this `MovieRepository` you want to create an "in-memory" implmentation of the `MovieRepositoryInterface`.

With this small library you can easily do this:

```
