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

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

pektiyaz/repository-contracts
=============================

Collection of repository contracts

v1.0.0(1y ago)01461MITPHP

Since Apr 7Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (1)

Repository Contracts
====================

[](#repository-contracts)

This repository defines a reusable and extensible set of contracts (interfaces) for implementing the Repository pattern in a clean and consistent way across Laravel applications.

✨ Purpose
---------

[](#-purpose)

These contracts provide a foundation for working with data access layers in a decoupled, testable, and flexible manner. By enforcing a contract-based structure, you can:

- Separate business logic from data access logic
- Write cleaner and more maintainable code
- Easily swap implementations or mock repositories in tests
- Support advanced querying via query filters

---

📦 Installation
--------------

[](#-installation)

You can install the Repository Contracts package using Composer:

```
composer require pektiyaz/repository-contracts
```

📦 Interfaces
------------

[](#-interfaces)

### `RepositoryContract`

[](#repositorycontract)

This is the primary interface for a repository. It defines common methods for working with entities:

#### 🔍 Basic Methods

[](#-basic-methods)

- `findById($id)`
- `findOneBy(array $conditions)`
- `findAllBy(array $conditions)`
- `findAll()`

#### ✏️ Write Operations

[](#️-write-operations)

- `create(array $data)`
- `update($id, array $data)`
- `delete($id)`
- `bulkCreate(array $records)`
- `bulkUpdate(array $conditions, array $data)`
- `bulkDelete(array $conditions)`

#### 📄 Pagination &amp; Existence

[](#-pagination--existence)

- `paginate(int $page, int $perPage, array $conditions = [])`
- `exists(array $conditions)`
- `count(array $conditions = [])`

#### 🗑️ Soft Deletes

[](#️-soft-deletes)

- `restore(int $id)`
- `findTrashed()`
- `findTrashedById($id)`
- `forceDelete($id)`

#### 🧠 Advanced Filtering

[](#-advanced-filtering)

- `filter(QueryFilterContract $filter)`
- `countByFilter(QueryFilterContract $filter)`
- `deleteByFilter(QueryFilterContract $filter)`
- `updateByFilter(QueryFilterContract $filter, array $data)`
- `findByCallback(callable $callback)`

Each method returns either a single `EntityContract`, an array of `EntityContract`, a boolean, an integer, or `null`, depending on the operation.

---

### `QueryFilterContract`

[](#queryfiltercontract)

Defines a contract for advanced query filtering using filter objects.

```
public function apply($query);
```

Let me know if you’d like to generate badges, link examples of concrete implementations, or include Laravel-specific helpers in the README.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance47

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

400d ago

### Community

Maintainers

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

---

Top Contributors

[![pektiyaz](https://avatars.githubusercontent.com/u/30262879?v=4)](https://github.com/pektiyaz "pektiyaz (5 commits)")

### Embed Badge

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

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

###  Alternatives

[phpdocumentor/type-resolver

A PSR-5 based resolver of Class names, Types and Structural Element Names

9.2k719.5M166](/packages/phpdocumentor-type-resolver)[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[stella-maris/clock

A pre-release of the proposed PSR-20 Clock-Interface

7947.5M2](/packages/stella-maris-clock)[wptrt/wpthemereview

PHP\_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org

217736.5k29](/packages/wptrt-wpthemereview)[inpsyde/modularity

Modular PSR-11 implementation for WordPress plugins, themes or libraries.

54383.3k3](/packages/inpsyde-modularity)

PHPackages © 2026

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