sinemacula/laravel-repositories
Laravel repositories package offering a structured repository pattern layer for cleaner, testable data access. It helps organize queries behind interfaces, keeping your models and controllers lean.
Architecture fit. sinemacula/laravel-repositories implements the repository pattern on top of Eloquent, providing a base repository class, a contract interface, and query/criteria abstractions. For teams already using a service-layer or hexagonal-ish structure inside Laravel, it slots in as a thin seam between controllers/services and models. It is an optional architectural layer, not a framework-level dependency, which keeps blast radius contained if adoption is later reversed.
Integration feasibility. Composer-installable package with no documented external service dependencies. v3.2.0 adds the ability to declare a repository's backing model via a PHP attribute (issue #87) rather than a property or method override. This is additive: it reduces boilerplate in the common case and makes model binding declarative, which is attractive for teams standardising repository definitions across many modules. Practical adoption requires PHP 8.0+ (attributes) and a Laravel version within the package's illuminate/* constraints — both must be verified against our runtime matrix before committing.
Technical risk. Low for this specific release: a single feature, minor version bump, no breaking changes, no deprecations signalled. The larger risk is package-level rather than release-level — it is a single-maintainer, community package. That implies (a) API stability is a convention rather than a guarantee, and (b) security/maintenance continuity depends on one individual's availability. Attribute-driven model declaration also introduces a small "magic" surface: resolution failures will surface at runtime rather than at static analysis time unless the attribute is typed and enforced.
Key questions.
illuminate/* and PHP constraints in v3.2.0's composer.json, and do they cover our current and next-year Laravel targets?$model property, and which wins on conflict?Stack fit. Good fit for a conventional Laravel app on PHP 8.0+ where controllers are already thin and business logic lives in services. Poor fit for codebases that lean on Eloquent as the domain model throughout — imposing repositories there adds indirection without reducing coupling.
Migration path. Adopt incrementally:
Because the attribute is purely additive, there is no forced migration. Existing repositories continue to work; the attribute is an ergonomics improvement for new code.
Compatibility. Confirm three axes before merge: PHP version (attributes need 8.0+), Laravel major (check the illuminate/support and illuminate/database constraints), and PHPUnit/PHPStan compatibility in CI. Also verify behaviour under Laravel Octane if we run it — reflection-based attribute resolution on every request would be a concern if uncached.
Sequencing. Package evaluation and constraint check first, then a single-context pilot, then a documented internal convention ("new repositories declare their model via attribute") only after the pilot proves stable. Do not adopt the attribute broadly in the same release cycle as the initial package introduction; separate the two decisions so regressions are attributable.
Maintenance. The package becomes a direct dependency we must track, including transitive illuminate/* constraints that can block Laravel upgrades. Budget for a periodic review each Laravel major. The repository layer itself adds code we own — interface + implementation per aggregate — so it increases our surface area modestly in exchange for testability.
Support. Upstream support is community/volunteer. There is no commercial SLA. If the maintainer steps away, we would be pinning a fork; the abstraction is small enough that in-housing the base repository class is a viable fallback, which materially de-risks adoption.
Scaling. The repository pattern is neutral to application scaling; it does not change query behaviour. Two scaling-relevant considerations: (1) avoid repositories becoming god-objects as query variants accumulate — enforce a review rule; (2) confirm attribute-based model resolution is memoised, otherwise Octane/queue workers pay reflection cost per resolution.
Failure modes.
$model property and attribute present; behaviour depends on package precedence, must be documented internally.illuminate/*, blocking a Laravel upgrade on our timetable.Ramp-up. Low-to-moderate. The repository pattern is familiar to most Laravel developers; the attribute syntax is a one-line convention that needs a short README-style note in our engineering docs. Expect roughly a day of onboarding for a mid-level developer plus review discipline to keep interfaces meaningful. The main ramp-up cost is cultural, not technical: agreeing what belongs in a repository so it does not become a second model layer.
How can I help you explore Laravel packages today?