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

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

jardisport/repository
=====================

Repository interface and contracts for raw-data CRUD persistence with primary key strategies

v1.0.0(1mo ago)064↓100%1proprietaryPHPPHP &gt;=8.2CI passing

Since Mar 18Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (3)Used By (1)

Jardis Repository Port
======================

[](#jardis-repository-port)

[![Build Status](https://github.com/jardisPort/repository/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisPort/repository/actions/workflows/ci.yml/badge.svg)[![License: PolyForm Shield](https://camo.githubusercontent.com/d8fb46c82be4c5312bf3e372ac734dfdf6a8b328e9c2b2856af671adbb0600a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d506f6c79466f726d253230536869656c642d626c75652e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/c51bda247654363d3e30bc352674dd761a9557803a14af0226eb411d6dc0006b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d627269676874677265656e2e737667)](phpstan.neon)[![PSR-12](https://camo.githubusercontent.com/34b10db0caa29bacd49bda5c437a8de95385f036f3230b31fa605326e18da22c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5053522d2d31322d626c75652e737667)](phpcs.xml)

> Part of the **[Jardis Business Platform](https://jardis.io)** — Enterprise-grade PHP components for Domain-Driven Design

Repository contract for raw-data CRUD persistence. Defines insert, update, delete, find, and exists operations with pluggable primary key strategies. Works with arrays — no entity coupling, no ORM dependency. The implementation can route reads and writes to separate database connections without your domain code knowing about it.

---

Interfaces
----------

[](#interfaces)

### **RepositoryInterface**

[](#repositoryinterface)

`JardisPort\Repository\RepositoryInterface`

Generic CRUD contract operating on associative arrays. All operations target a named table with an explicit primary key column.

MethodSignatureDescription`insert``insert(string $table, string $pkColumn, array $values, PkStrategy $pkStrategy = PkStrategy::AUTOINCREMENT): int|string`Insert a record. Returns the generated primary key.`update``update(string $table, string $pkColumn, int|string $id, array $values): bool`Update an existing record by primary key.`delete``delete(string $table, string $pkColumn, int|string $id): bool`Delete a single record by primary key.`deleteAll``deleteAll(string $table, string $pkColumn, array $ids): void`Delete multiple records by a list of primary keys.`findById``findById(string $table, string $pkColumn, int|string $id): ?array`Find a single record by primary key. Returns `null` when not found.`findByQuery``findByQuery(DbQueryBuilderInterface $query): array`Execute a fully built SELECT query and return all matching rows.`exists``exists(string $table, string $pkColumn, int|string $id): bool`Check whether a record with the given primary key exists.### **PkStrategy**

[](#pkstrategy)

`JardisPort\Repository\PrimaryKey\PkStrategy`

Enum controlling how the primary key is generated on insert.

CaseDescription`AUTOINCREMENT`Database generates the key (standard auto-increment).`INTEGER`Caller provides an integer key.`NONE`No primary key handling — composite keys or special cases.### Exceptions

[](#exceptions)

ClassDescription`PersistException`Thrown when an insert, update, or delete operation fails.`RecordNotFoundException`Thrown when a required record does not exist.---

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

[](#installation)

```
composer require jardisport/repository
```

Usage
-----

[](#usage)

```
use JardisPort\Repository\RepositoryInterface;
use JardisPort\Repository\PrimaryKey\PkStrategy;
use JardisPort\Repository\Exception\RecordNotFoundException;

class ProductRepository
{
    public function __construct(
        private readonly RepositoryInterface $repository,
    ) {}

    public function create(array $data): int|string
    {
        return $this->repository->insert('products', 'id', $data, PkStrategy::AUTOINCREMENT);
    }

    public function findOrFail(int $id): array
    {
        $record = $this->repository->findById('products', 'id', $id);

        if ($record === null) {
            throw new RecordNotFoundException("Product $id not found");
        }

        return $record;
    }

    public function remove(int $id): bool
    {
        return $this->repository->delete('products', 'id', $id);
    }
}
```

Implemented by
--------------

[](#implemented-by)

- **[jardissupport/repository](https://github.com/jardisSupport/repository)** — PDO-based implementation with read/write splitting, connection pool support, and configurable primary key strategies

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

[](#documentation)

Full documentation, guides, and API reference:

**[jardis.io/docs/port/repository](https://jardis.io/docs/port/repository)**

License
-------

[](#license)

This package is licensed under the [PolyForm Shield License 1.0.0](LICENSE.md). Free for all use except building competing frameworks or developer tooling.

---

**[Jardis](https://jardis.io)** · [Documentation](https://jardis.io/docs) · [Headgent](https://headgent.com)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance90

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

53d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

interfacesrepositorydddHeadgentJardisPort

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[nilportugues/repository

Implementation of a base repository

272.9k6](/packages/nilportugues-repository)

PHPackages © 2026

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