PHPackages                             solophp/base-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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. solophp/base-repository

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

solophp/base-repository
=======================

Base repository pattern implementation for PHP applications

v3.0.0(2w ago)04MITPHPPHP ^8.3CI passing

Since Sep 22Pushed 2w agoCompare

[ Source](https://github.com/SoloPHP/Base-Repository)[ Packagist](https://packagist.org/packages/solophp/base-repository)[ RSS](/packages/solophp-base-repository/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (12)Versions (20)Used By (0)

Solo Base Repository
====================

[](#solo-base-repository)

Lightweight PHP repository pattern with built-in soft delete, eager loading, and rich criteria syntax.

[![Latest Version](https://camo.githubusercontent.com/a957b97b791f99eb613b4686ee1bc57ae37bf6b259b66713a5a80ae8a7d848d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6c6f7068702f626173652d7265706f7369746f72792e737667)](https://packagist.org/packages/solophp/base-repository)[![PHP Version](https://camo.githubusercontent.com/2fcffdf4a6fdfa5bf09f7dd43da963940e308396313cb850f33ef292883d64d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6c6f7068702f626173652d7265706f7369746f72792e737667)](https://packagist.org/packages/solophp/base-repository)[![License](https://camo.githubusercontent.com/8209f0bb80d13d19547144fbe0ae3d4ef5d9afc4133b1214d17de6692b8d62a4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f736f6c6f7068702f626173652d7265706f7369746f72792e737667)](LICENSE)

Features
--------

[](#features)

- Soft delete with restore/force delete
- Eager loading (BelongsTo, HasOne, HasMany, BelongsToMany)
- Rich criteria syntax: operators, BETWEEN, OR/AND groups, and correlated EXISTS via relation dot-notation
- Named scopes: virtual criteria keys expanded into reusable criteria fragments (ideal for HTTP filters)
- Built-in aggregations (count, sum, avg, min, max)
- Translation via `withLocale()` with optional fallback locale — auto LEFT JOIN, propagates into relations; `seedTranslations()` fills all locales on create (cross-platform)
- Transaction helpers with row locking (`SELECT ... FOR UPDATE`) and cross-process advisory locks (`withLock()`) for idempotency
- Custom IDs (UUID, ULID, prefixed) via `$autoIncrement = false`

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

[](#installation)

```
composer require solophp/base-repository
```

**Requirements:** PHP 8.3+, Doctrine DBAL ^4.3

**Database:** any Doctrine DBAL platform. Locking is platform-specific: `lockForUpdate()` — MySQL/MariaDB, PostgreSQL, Oracle; `withLock()` advisory locking — MySQL/MariaDB (`GET_LOCK`) and PostgreSQL (`pg_advisory_lock`). Other platforms throw on these calls.

Quick Example
-------------

[](#quick-example)

```
class UserRepository extends BaseRepository
{
    protected ?string $deletedAtColumn = 'deleted_at';

    public function __construct(Connection $connection)
    {
        parent::__construct($connection, User::class, 'users');
    }
}

// Usage
$users = $repo->findBy(['status' => 'active'], ['created_at' => 'DESC'], 20, 1);
$repo->delete($id);      // Soft delete
$repo->restore($id);     // Restore
```

Documentation
-------------

[](#documentation)

📖 **[Full Documentation](https://solophp.github.io/Base-Repository/)**

- [Installation](https://solophp.github.io/Base-Repository/guide/installation)
- [Quick Start](https://solophp.github.io/Base-Repository/guide/quick-start)
- [Criteria Syntax](https://solophp.github.io/Base-Repository/features/criteria)
- [Scopes](https://solophp.github.io/Base-Repository/features/scopes)
- [Soft Delete](https://solophp.github.io/Base-Repository/features/soft-delete)
- [Eager Loading](https://solophp.github.io/Base-Repository/features/eager-loading)
- [Translations](https://solophp.github.io/Base-Repository/features/translations)
- [API Reference](https://solophp.github.io/Base-Repository/methods/retrieval)

License
-------

[](#license)

MIT

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance94

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

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

Total

19

Last Release

20d ago

Major Versions

v1.7.0 → v2.0.02025-12-26

v2.7.0 → v3.0.02026-06-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f29817cec408d033cd4441c8f760e3ae40248dc0f66856a09080d282aee6959?d=identicon)[Vitaliy Olos](/maintainers/Vitaliy%20Olos)

---

Top Contributors

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

---

Tags

psrphpcrudrepositorypatternphp8strict types

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M223](/packages/backpack-crud)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[lctrs/psalm-psr-container-plugin

Let Psalm understand better psr11 containers

17679.3k13](/packages/lctrs-psalm-psr-container-plugin)[contao-community-alliance/dc-general

Universal data container for Contao

1680.8k91](/packages/contao-community-alliance-dc-general)

PHPackages © 2026

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