PHPackages                             sinemacula/laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sinemacula/laravel-repositories

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sinemacula/laravel-repositories
===============================

Provides the repository data pattern to Laravel applications

v2.0.2(3mo ago)018.5k↓61.9%1Apache-2.0PHPPHP ^8.3CI passing

Since Aug 6Pushed 1w ago1 watchersCompare

[ Source](https://github.com/sinemacula/laravel-repositories)[ Packagist](https://packagist.org/packages/sinemacula/laravel-repositories)[ RSS](/packages/sinemacula-laravel-repositories/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (7)Dependencies (43)Versions (13)Used By (1)

Laravel Repositories
====================

[](#laravel-repositories)

[![Latest Stable Version](https://camo.githubusercontent.com/7450af0886ea87d700bff294ea81314b32662d98faf0c1794ed264dc8d74243d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73696e656d6163756c612f6c61726176656c2d7265706f7369746f726965732e737667)](https://packagist.org/packages/sinemacula/laravel-repositories)[![Build Status](https://github.com/sinemacula/laravel-repositories/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/sinemacula/laravel-repositories/actions/workflows/tests.yml)[![Maintainability](https://camo.githubusercontent.com/419523aa80275bc60e9f2a12881caa9f8c72c85d9b6f9b74e1c871dd4b9e57c3/68747470733a2f2f716c74792e73682f67682f73696e656d6163756c612f70726f6a656374732f6c61726176656c2d7265706f7369746f726965732f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/sinemacula/projects/laravel-repositories)[![Code Coverage](https://camo.githubusercontent.com/0d8e1c6bc537f26641f160ec3c28627883563fe2dded7a02262f537ba9902289/68747470733a2f2f716c74792e73682f67682f73696e656d6163756c612f70726f6a656374732f6c61726176656c2d7265706f7369746f726965732f636f7665726167652e737667)](https://qlty.sh/gh/sinemacula/projects/laravel-repositories)[![Total Downloads](https://camo.githubusercontent.com/964b213dd92664a0d863c9a6823a19682e70ca6c35acaaaa7cc34a0cf850d55d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73696e656d6163756c612f6c61726176656c2d7265706f7369746f726965732e737667)](https://packagist.org/packages/sinemacula/laravel-repositories)

This Laravel package provides a streamlined repository pattern layer for Eloquent models with criteria-driven query composition. It keeps the parts of l5-repository that are most useful in modern Laravel applications while removing unnecessary abstraction and maintenance overhead.

A big thanks to the creators of [andersao/l5-repository](https://github.com/andersao/l5-repository) for the original foundation this package builds on.

Features
--------

[](#features)

- **Repository Base Class**: A container-resolved repository abstraction with explicit model validation, lifecycle reset behavior, and a `boot()` extension point for subclass initialization.
- **Criteria Lifecycle Controls**: Persistent and one-shot criteria pipelines with runtime enable, disable, skip, and reset controls.
- **Supplementary Capability Contracts**: Opt-in interfaces that criteria can implement to declare eager-loading (`DeclaresEagerLoading`), field selection (`DeclaresFieldSelection`), relationship counts (`DeclaresRelationshipCounts`), and metadata (`ContributesMetadata`) alongside query modification. The repository collects these declarations at criteria application time and exposes them via dedicated accessors.
- **Scoped Query Mutation**: Per-query scope registration for concise query customization without polluting models.
- **Model-Like Ergonomics**: Explicit query entrypoints (`query()` / `newQuery()`) plus magic forwarding for model-style usage such as `Repository::find($id)`.

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

[](#installation)

To install the Laravel API Repositories package, run the following command in your project directory:

```
composer require sinemacula/laravel-repositories
```

Usage
-----

[](#usage)

```
// Explicit query entrypoint
$users = $userRepository->query()->where('active', true)->get();

// Magic forwarding remains available for model-like usage
$user = UserRepository::find($id);
```

### Container Lifecycle

[](#container-lifecycle)

Repositories carry transient criteria and scope state while a query pipeline is being built. Register repositories as transient or scoped bindings (`bind` or `scoped`) rather than `singleton` to avoid state leakage across requests.

Testing
-------

[](#testing)

```
composer test
composer test-coverage
composer check
```

Versioning Policy
-----------------

[](#versioning-policy)

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

**What constitutes a breaking change:**

- Adding, removing, or changing method signatures on any interface (`CriteriaInterface`, `RepositoryInterface`, `RepositoryCriteriaInterface`, `ContributesMetadata`, `DeclaresEagerLoading`, `DeclaresFieldSelection`, `DeclaresRelationshipCounts`)
- Changing the observable behavior of public methods in ways that violate documented contracts
- Changing protected members that are classified as [stable extension points](UPGRADING.md)

**Deprecation policy:**

- Features planned for removal will be marked with `@deprecated` annotations that include a description, the recommended replacement, and the version in which the feature will be removed.
- Deprecated features will survive at least one minor or major release cycle before removal.
- PHPStan (with `phpstan-deprecation-rules`) will surface deprecation warnings in your IDE and CI pipeline.

**What is NOT covered by stability guarantees:**

- Members marked `@internal` (including the `ManagesCriteria` trait)
- Protected properties and methods not classified as stable extension points
- Undocumented behavioral details (e.g., internal criteria application ordering)

See [CHANGELOG.md](CHANGELOG.md) for a history of changes, [UPGRADING.md](UPGRADING.md) for migration guidance between major versions, and [EXTENSION-POINTS.md](EXTENSION-POINTS.md) for the extension point classification and lifecycle documentation.

Contributing
------------

[](#contributing)

Contributions are welcome via GitHub pull requests.

Security
--------

[](#security)

If you discover a security issue, please contact Sine Macula directly rather than opening a public issue.

License
-------

[](#license)

Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance91

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 89.6% 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 ~86 days

Recently: every ~11 days

Total

8

Last Release

90d ago

Major Versions

v1.0.4 → v2.0.02026-02-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/6262ea965c244b0c946a2f29a94da05e30846c066a0b59399466216654c78fe6?d=identicon)[sinemacula](/maintainers/sinemacula)

---

Top Contributors

[![sinemacula-ben](https://avatars.githubusercontent.com/u/118753672?v=4)](https://github.com/sinemacula-ben "sinemacula-ben (60 commits)")[![maticb](https://avatars.githubusercontent.com/u/3185053?v=4)](https://github.com/maticb "maticb (2 commits)")[![qltysh[bot]](https://avatars.githubusercontent.com/in/890766?v=4)](https://github.com/qltysh[bot] "qltysh[bot] (2 commits)")[![sine-macula-dependencies[bot]](https://avatars.githubusercontent.com/in/4130001?v=4)](https://github.com/sine-macula-dependencies[bot] "sine-macula-dependencies[bot] (2 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelrepositoriessine macula

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sinemacula-laravel-repositories/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)[wearepixel/laravel-cart

A cart implementation for Laravel

1374.8k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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