jooservices / laravel-repository
PHP 8.5+ Laravel repository package for trait-based CRUD, filtering, ordering, and request-driven query composition
Requires
- php: >=8.5
- illuminate/console: ^12.0|^13.0
- illuminate/contracts: ^12.0|^13.0
- illuminate/database: ^12.0|^13.0
- illuminate/filesystem: ^12.0|^13.0
- illuminate/http: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- psr/simple-cache: ^3.0
Requires (Dev)
- captainhook/captainhook: ^5.23
- captainhook/plugin-composer: ^5.3
- fakerphp/faker: ^1.24
- friendsofphp/php-cs-fixer: ^3.65
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^10.0|^11.0
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^12.0 || ^13.0
- squizlabs/php_codesniffer: ^3.8 || ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-06 02:23:47 UTC
README
JOOservices Laravel Repository is a PHP 8.5+ Laravel package for trait-based repository composition: CRUD, filtering, ordering, criteria, and request-driven query composition on Eloquent.
Composer package: jooservices/laravel-repository — current line: v4.0.0.
Upgrading from 1.x: see UPGRADE-4.0.md.
Install
composer require jooservices/laravel-repository:^4.0
Optionally publish config and stubs:
php artisan vendor:publish --tag=laravel-repository-config php artisan vendor:publish --tag=laravel-repository-stubs
Quick example
use App\Models\User; use JOOservices\LaravelRepository\Repositories\Presets\ApiRepository; /** @extends ApiRepository<User> */ final class UserRepository extends ApiRepository { public function __construct(User $model) { parent::__construct($model); } } $repository = app(UserRepository::class); $user = $repository->find($id); $users = $repository->filter(['status' => 'active'])->orderBy(['-created_at'])->paginate(15);
Scaffold:
php artisan make:repository UserRepository --model=User --preset=api
See the Cookbook for profiles, value rules, soft deletes, locking, and debug helpers.
What is supported today
- trait-based composition through segregated contracts and traits
- presets
ApiRepository/ReadRepositoryand Artisanmake:repository - CRUD (
HasCrud) includingfindMany,findBy,updateOrCreate,upsert - filters, pagination, and
simplePaginate(HasFilter) - ordering and sort shorthand (
HasOrder) - request-driven queries (
HasRequestQuery) with allowlists / strict mode - named filters, field selection, scopes, relation filters, aggregate includes
- operators including
exact,partial,before,after,date,jsonContains - criteria (
HasCriteria), soft deletes, locking, SQL debug - named query profiles with restrictive baseline semantics
- cursor pagination that preserves sparse and Expression projections
- opt-in cache wrappers (
HasCache) with stable typed cache keys - reusable
FilterandOrdervalue objects
Important boundaries
- capabilities are opt-in through traits; nothing is globally implied
- query state is lazy and resets after terminal operations
RequestQueryParsersupports only the documented clause families- relation methods should declare a
Relationreturn type (or use an explicit trust / allowlist path)
Documentation
- Documentation Hub
- Installation
- Quick Start
- Request Query Support
- Examples
- Cookbook
- Upgrade 4.0
- Changelog
Development
composer lint
composer test
composer check
Contributor workflow:
Project agents: AGENTS.md (workspace policy in the JOOservices root
AGENTS.md).
License
This project is licensed under the MIT License.