nilportugues/eloquent-repository
A Laravel package that adds a repository layer for Eloquent models, with reusable query criteria, caching support, and cleaner separation between persistence and application logic.
Architecture fit
php-eloquent-repository layers a repository abstraction over Laravel's Eloquent ORM, exposing read/write contracts (ReadRepository, WriteRepository) with framework-agnostic interfaces that can be bound in a service provider.chunk/cursor, query scopes, aggregates) unless the package exposes them, which creates pressure to bypass the repository.count and exists, which are the two most common lightweight checks. This is a positive signal that the read surface is maturing toward practical parity rather than a bespoke subset.Integration feasibility
DivisionByZeroError versus a silently wrong page count changes the blast radius.Technical risk
count and exists to ReadRepository is a contract expansion. Any consumer that implements ReadRepository directly — custom repository, test double, decorator, or a mock generated against the interface — will break at runtime or fail static analysis. This shipped in a patch release (2.2.2). Mitigate by pinning to an exact version and running a full test suite before/after.Key questions
ReadRepository interface change explicitly classified as breaking, and is there a 2.3.0 planned (or should 2.2.2 have been minor)?count/exists respect the same criteria/scope pipeline as the other read methods, or do they bypass it?composer.json?Stack fit
composer.json constraints against the team's Laravel and PHP versions before committing; do not assume 2.2.2 back-ports to older majors.Migration path
ReadRepository (including test doubles) and add count/exists where required.Compatibility
composer.lock with ~2.2.0, a composer update will pull 2.2.2 silently. Tighten to 2.2.2 exactly until the upgrade is validated, or add a CI job that diffs the public interface between versions.Sequencing
ReadRepository implementers and test doubles; patch them.count/exists incrementally where they replace hand-rolled ->count() / ->exists() calls, keeping behavior identical.Maintenance
Support
Scaling
count/exists calls that scan when an index-backed check would do.exists is the cheaper primitive; prefer it over count() > 0 in hot paths and standardize that in code review.Failure modes
perPage = 0, and last-page boundaries.Ramp-up
exists-over-count convention.How can I help you explore Laravel packages today?