sinemacula / laravel-repositories
Provides the repository data pattern to Laravel applications
Installs: 14 424
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/sinemacula/laravel-repositories
Requires
- php: ^8.3
- illuminate/database: *
- illuminate/support: *
Requires (Dev)
- brianium/paratest: ^7.8
- friendsofphp/php-cs-fixer: ^3.85
- orchestra/testbench: ^9.0 || ^10.0
- phpstan/extension-installer: ^1.4
- phpstan/phpdoc-parser: ^2.2
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^11.5.3
- slevomat/coding-standard: ^8.20
- squizlabs/php_codesniffer: ^3.13
This package is auto-updated.
Last update: 2026-02-21 05:50:10 UTC
README
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 for the original foundation this package builds on.
Features
- Repository Base Class: A container-resolved repository abstraction with explicit model validation and lifecycle reset behavior.
- Criteria Lifecycle Controls: Persistent and one-shot criteria pipelines with runtime enable, disable, skip, and reset controls.
- 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 asRepository::find($id).
Installation
To install the Laravel API Repositories package, run the following command in your project directory:
composer require sinemacula/laravel-repositories
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
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
composer test
composer test-coverage
composer check
Contributing
Contributions are welcome via GitHub pull requests.
Security
If you discover a security issue, please contact Sine Macula directly rather than opening a public issue.
License
Licensed under the Apache License, Version 2.0.