jooservices/laravel-repository
Composer 安装命令:
composer require jooservices/laravel-repository
包简介
PHP 8.5+ Laravel repository package for trait-based CRUD, filtering, ordering, and request-driven query composition
README 文档
README
The JOOservices Laravel Repository package is a PHP 8.5+ Laravel package for trait-based repository composition, CRUD, filtering, ordering, and request-driven query composition.
Package name: jooservices/laravel-repository
Install
composer require jooservices/laravel-repository
Optionally publish the package config:
php artisan vendor:publish --tag=laravel-repository-config
Quick example
use App\Models\User; use Jooservices\LaravelRepository\Contracts\RepositoryInterface; use Jooservices\LaravelRepository\Repositories\EloquentRepository; use Jooservices\LaravelRepository\Traits\HasCrud; use Jooservices\LaravelRepository\Traits\HasFilter; use Jooservices\LaravelRepository\Traits\HasOrder; final class UserRepository extends EloquentRepository implements RepositoryInterface { use HasCrud; use HasFilter; use HasOrder; public function __construct(User $model) { parent::__construct($model); } } $repository = app(UserRepository::class); $user = $repository->find($id); $users = $repository->filter(['status' => 'active'])->orderBy(['created_at' => 'desc'])->paginate(15);
What is supported today
- trait-based repository composition through segregated contracts and traits
- CRUD operations through
HasCrud - filter chains, collection retrieval, and pagination through
HasFilter - ordering through
HasOrder - request-driven query parsing through
HasRequestQuery - opt-in request-query allowlists and strict mode through
HasAllowedRequestQuery - request-driven field selection, named request filters, callback micro filters, request-query aliases, aggregate include helpers, and value-normalization rules
- first-class request operators such as
exact,partial,beginsWith, andendsWith, plus safe aliases likeeq,neq,gt,gte,lt,lte, andlike - opt-in request scopes, scope definitions, relation count clauses, nested relation filters including
whereHasandwhereDoesntHavevariants, derived count or exists includes, additional sum or avg or min or max aggregate includes, and cursor pagination - reusable criteria stacks through
HasCriteria - read terminals such as
first,firstOrFail,exists, andcountthroughHasRead - chunk, lazy, cursor, and
lazyByIditeration throughHasIteration - safe request pagination through
paginateFromRequest() - opt-in cache wrappers and cache-key helpers through
HasCache - reusable
FilterandOrdervalue objects
Important current boundaries
- repositories opt into behavior through traits; no feature is globally implied
- query state is lazily created and reset after terminal filter operations
RequestQueryParsersupports only the implemented clause families
Documentation
Start with:
- Documentation Hub
- Installation
- Quick Start
- Trait-Based Composition
- Examples
- Competitive Comparison And Roadmap
- Risks, Legacy, and Gaps
AI Support
This repository includes an AI skill pack for agents working in Cursor, Claude Code, VS Code, JetBrains, and Antigravity.
Start with:
The canonical skill source lives in .github/skills/, with adapter layers for each supported AI environment.
Development
composer lint:all
composer test
Contributor workflow details live in:
GitHub Actions and Services
The repository workflow set is designed to include CI, release, PR labeler, semantic PR title, scorecard, and secret-scanning workflows.
The CI baseline covers security checks, linting, tests with coverage artifacts, and optional dependency review. Release is tag-driven through vX.Y.Z tags.
Current external service integrations:
Codecovfor CI coverage uploads whenCODECOV_TOKENis configuredPackagistfor release-time package update notifications
Changelog
See CHANGELOG.md for version history.
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 340
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-09