therockersenior/l5-repository
A Laravel repository pattern package that adds Criteria, Presenters, Fractal transformers, and caching to keep your controllers slim and your data layer reusable and testable across projects.
BaseRepository (typically 150–300 lines of CRUD, criteria, and pagination plumbing) plus ongoing maintenance. This package is MIT-licensed and battle-tested by ~4.2k stargazers, so the decision becomes "adopt a convention" rather than "fund an internal framework." Useful when you're deciding whether to spend sprint capacity on infrastructure or on customer-facing features.Interface → Repository → Service → Controller). That reduces review variance and makes "can we parallelize this workstream across two squads?" a defensible yes.Adopt when most of these hold:
Model::query() calls scattered through controllers.Look elsewhere when:
whereHas chains degrade badly behind a generic repository interface — you end up leaking the query builder anyway, which is the worst of both worlds.l5- naming and a single-maintainer bus factor are real risks; verify support for your Laravel/PHP target and read the changelog cadence before committing. Zero dependents in the ecosystem is a mild signal that upstream integration is thin.To executives: This is a low-cost, MIT-licensed library that standardizes how our application talks to the database. It buys us three things: faster delivery on data-heavy features, the ability to change or add a data source later without rewriting business logic, and cheaper tests because most logic can be verified without a live database. The cost is a small amount of upfront structure and roughly a week of team alignment. The main risk is dependency hygiene — it's maintained by a small team, so we should budget a periodic review of whether it still tracks our Laravel version.
To engineering: Adopt it as the persistence convention, not as an architecture. Define one interface per aggregate, keep repositories thin (query composition and persistence only), and forbid business logic inside them. Use criteria for cross-cutting concerns — tenancy, soft-delete filters, caching keys — and resist the urge to hide every Eloquent feature behind the interface; when a query genuinely needs the query builder, expose it deliberately rather than pretending the abstraction holds. Invest early in a base test double and a lint rule that keeps controllers out of models. Set an explicit review checkpoint each Laravel major upgrade: if the package lags more than one release cycle, we fork the base classes — they're small enough that this is a contained exit, not a crisis.
How can I help you explore Laravel packages today?