PHPackages                             carlosv2/dumbsmart-repositories - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. carlosv2/dumbsmart-repositories

ActiveLibrary[Testing &amp; Quality](/categories/testing)

carlosv2/dumbsmart-repositories
===============================

Simplistic layer to store documents into their own repositories

1.2.0(7y ago)03.8k21MITPHPPHP ~5.3 || ~7.0

Since Mar 22Pushed 7y ago1 watchersCompare

[ Source](https://github.com/carlosV2/DumbsmartRepositories)[ Packagist](https://packagist.org/packages/carlosv2/dumbsmart-repositories)[ RSS](/packages/carlosv2-dumbsmart-repositories/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (1)

Dumbsmart Repositories
----------------------

[](#dumbsmart-repositories)

This project provides a layer that sits in between your project and a collection of fake repositories so that each document is stored into its own repository regardless of whether it was persisted as a relation of another object. This layer is designed to be used on testing environments or on low data-level-access applications. Using this project in production is discouraged.

[![License](https://camo.githubusercontent.com/b48b3a221074894420d5687fd18afa7fb207ec068a1adf46d5fe64fff04f4b25/68747470733a2f2f706f7365722e707567782e6f72672f6361726c6f7376322f64756d62736d6172742d7265706f7369746f726965732f6c6963656e7365)](https://packagist.org/packages/carlosv2/dumbsmart-repositories)[![Build Status](https://camo.githubusercontent.com/c9bb833c93cc16c79560ecb1f95f75c1050b501c22eb793b069201fa31590d0e/68747470733a2f2f7472617669732d63692e6f72672f6361726c6f7356322f44756d62736d6172745265706f7369746f726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/carlosV2/DumbsmartRepositories)[![SensioLabsInsight](https://camo.githubusercontent.com/cbdb2e34c4a4721b4bd51922b93a06022ccbf8859203550313c05dc31d96783f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35303030313163322d343633352d343832372d623030652d6332353362333530323137312f6d696e692e706e67)](https://insight.sensiolabs.com/projects/500011c2-4635-4827-b00e-c253b3502171)

Why?
----

[](#why)

When using fake repositories is common to use functions like `serialize` or `json_encode` in order to make data easily persistable. A side effects of using these methods is that related documents are stored along with the parent document. As a result, querying this document from its own repository produces no results, and modifying its data means loading any potential document related with the one that must be modified. This is usually not a problem for small projects, but with large projects where data is complex, unforseen consequences can ensue.

### Installation

[](#installation)

Install with:

```
$ composer require --dev carlosv2/dumbsmart-repositories
```

### Usage

[](#usage)

Imagine you have the following entities:

```
class User
{
    private $id;
    private $posts;

    public function __construct($id) { $this->id = $id; }
    public function getId() { return $this->id; }
    public function setPosts(array $posts) { $this->posts = $posts; }
}

class Post
{
    private $id;

    public function __construct($id) { $this->id = $id; }
    public function getId() { return $this->id; }
}
```

In order to use them, you first need to configure this layer:

```
// Configure the metadata
$metadataManager = new MetadataManager();

$userMetadata = new Metadata(new AccessorObjectIdentifier('getId'));
$userMetadata->setRelation(new OneToManyRelation('posts'));
$metadataManager->addMetadata(User::class, $userMetadata);

$postMetadata = new Metadata(new AccessorObjectIdentifier('getId'));
$metadataManager->addMetadata(Post::class, $postMetadata);

// Configure the repositories
$repositoryManager = new RepositoryManager();
$repositoryManager->addRepository(User::class, new InMemoryRepository(new AccessorObjectIdentifier('getId')));
$repositoryManager->addRepository(Post::class, new InMemoryRepository(new AccessorObjectIdentifier('getId')));

// Create the persister object
$transactionFactory = new TransactionFactory($metadataManager, $repositoryManager);
$persister = new Persister($repositoryManager, $transactionFactory);
```

Once you have configured the layer, you can start using it like this:

```
$post1 = new Post(1);
$post2 = new Post(2);

$user = new User(1);
$user->setPosts([$post1, $post2]);

$persister->save($user);

// This returns an object with same properties as $post2. However it does
// not return same object because it has been serialized and unserialized
$persister->findById(Post::class, 2);
```

If you were using [everzet/persisted-objects](https://github.com/everzet/persisted-objects) previously, you don't even need to modify your code, only the way you build your repositories:

```
// $persister is an instance of carlosV2\DumbsmartRepositories\Persister
$persister = ... ;

// FrontRepository implements Everzet\PersistedObjects\Repository
$frontRepository = new FrontRepository($persister, YourVeryOwnClass::class);
$repository = new YourVeryOwnClassRepository($frontRepository);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

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

Recently: every ~139 days

Total

6

Last Release

2902d ago

PHP version history (4 changes)1.0.0PHP &gt;=5.4,&lt;7.1

1.0.1PHP &gt;=5.4,&lt;7.2

1.1.1PHP &gt;=5.3,&lt;7.2

1.2.0PHP ~5.3 || ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/7bd7a8f2b6884a04c3282dea24b9e0f10e0ff33e085bcc0e48797c4afc7d8758?d=identicon)[carlosV2](/maintainers/carlosV2)

---

Top Contributors

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

---

Tags

filesystemtestrepository

### Embed Badge

![Health badge](/badges/carlosv2-dumbsmart-repositories/health.svg)

```
[![Health](https://phpackages.com/badges/carlosv2-dumbsmart-repositories/health.svg)](https://phpackages.com/packages/carlosv2-dumbsmart-repositories)
```

###  Alternatives

[infyomlabs/laravel-generator

InfyOm Laravel Generator

3.8k2.3M13](/packages/infyomlabs-laravel-generator)[everzet/persisted-objects

Overly simplistic persistance implementations for functional testing

13170.8k4](/packages/everzet-persisted-objects)

PHPackages © 2026

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