PHPackages                             olajoscs/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. olajoscs/repository

ActiveLibrary

olajoscs/repository
===================

A small repository layer.

1.0.0(9y ago)041[2 issues](https://github.com/olajoscs/Repository/issues)MITPHPPHP &gt;=5.5.0

Since Apr 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/olajoscs/Repository)[ Packagist](https://packagist.org/packages/olajoscs/repository)[ Docs](https://github.com/olajoscs/Repository)[ RSS](/packages/olajoscs-repository/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Repository
==========

[](#repository)

This is a minimal Model/Repository package based on the [QueryBuilder](https://github.com/olajoscs/QueryBuilder) package. Minimum requirements: PHP 5.5+ with the requirements of the [QueryBuilder](https://github.com/olajoscs/QueryBuilder).

Model
=====

[](#model)

To create a model which is handled by the repository, simply extend the Model class.

```
use OlajosCs\Repository\Model;
class MyModel extends Model {}

```

Then 3 methods has to be defined in the model:

- validate(): returns void, which should throw a ValidationExcpetion when an object is not completely ready to put into the database,
- static getTableName(): returns string, the name of the database table, which is related to the model,
- static getIdField(): returns string, which defines what the name of the ID field is in the database table.

Repository
==========

[](#repository-1)

To create a repository which handles the model objects, simply extend the Repository class.

```
use OlajosCs\Repository\Repository
class MyObjectRepository extends Repository {}

```

There is only one method, which has to be defined:

- getModelClass(): string, returns the name of the class, which is the model. (MyModel::class)

Functionality
=============

[](#functionality)

- create(): Return a new, empty model
- get($id): Return a model, which has the ID of $id. If it does not exist, exception is thrown.
- getOrNew($id): Return a model, which has the ID of $id. If it does not exist, then a new empty one is returned.
- getList(): Return an array of all the models available in the database.
- save(Model $model): Save the model into the database. Create or update.
- delete(Model $model): Delete the model from the database.
- getWhereIdIn(array $ids): Return an array of the models, which have the ID listed in the array.
- getWhereIdInWithKeys(array $ids): Same as getWhereIdIn($ids), but the key of the returned array is the ID of the model.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3325d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/47fabfd1980b2e2628bca1a93867e391932a1a5fe59ff3131dd3b59b44b031ad?d=identicon)[olajoscs](/maintainers/olajoscs)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/olajoscs-repository/health.svg)

```
[![Health](https://phpackages.com/badges/olajoscs-repository/health.svg)](https://phpackages.com/packages/olajoscs-repository)
```

PHPackages © 2026

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