Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Repository Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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.
  • Fits teams already committed to a service-layer / hexagonal style where domain services depend on interfaces rather than Eloquent models. Improves testability (in-memory or mock repositories) and centralizes query logic.
  • Known trade-off: a repository over Eloquent is a contested pattern — Eloquent already is an Active Record + query builder abstraction. Expect leaky abstractions (eager loading, chunk/cursor, query scopes, aggregates) unless the package exposes them, which creates pressure to bypass the repository.
  • 2.2.2 completes the read contract with 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

  • Low friction to adopt: Composer install, Laravel package auto-discovery, bind interfaces to Eloquent-backed implementations. No infrastructure dependencies (no queue, cache, or external service required).
  • 2.2.2 changes are additive on the read side plus a defect fix, so net-new integration cost is essentially zero for teams already on the 2.2.x line.
  • The division-by-zero fix most plausibly touches pagination (per-page or total-based divisor). Confirm what the prior behavior was — a thrown DivisionByZeroError versus a silently wrong page count changes the blast radius.

Technical risk

  • Semver concern (highest priority): adding 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.
  • Behavioral change in the fix: the division-by-zero correction alters behavior on an edge case (likely zero page size or zero result totals). Any code relying on the prior exception or on a specific pagination result on empty sets should be re-validated.
  • Opaque release notes: both entries are bare commit links with no migration notes, no stated breaking-change classification, and no test evidence. Treat as under-documented.
  • Abstraction leakage: as read methods are added incrementally, the API surface grows toward Eloquent parity. Each addition is a new compatibility surface to track.
  • Bus factor / governance: verify maintainer count, release cadence, and issue responsiveness before making this a load-bearing dependency.

Key questions

  1. Is the ReadRepository interface change explicitly classified as breaking, and is there a 2.3.0 planned (or should 2.2.2 have been minor)?
  2. What was the exact pre-fix behavior of the division-by-zero path, and which inputs triggered it?
  3. Do count/exists respect the same criteria/scope pipeline as the other read methods, or do they bypass it?
  4. What are the supported Laravel and PHP version constraints in 2.2.2's composer.json?
  5. Is there a published changelog, upgrade guide, and CI/test coverage signal?
  6. How many active maintainers and what is the median time-to-merge for issues?

Integration Approach

Stack fit

  • Aligns with a standard Laravel stack: Composer, service providers, interface binding, PHPUnit/Pest. No new runtime, no new deployment topology.
  • Best fit: mid-size to large Laravel applications with a defined service/domain layer and a testing culture. Poor fit for small CRUD apps or teams that lean heavily on Eloquent's expressive query API.
  • Validate 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

  • Greenfield: adopt from day one — define repository interfaces per aggregate, implement against the package's base classes, bind in a provider.
  • Brownfield: strangler pattern. Extract one read-heavy or high-churn domain at a time; wrap existing query-builder/model calls behind the new interface first (behavior-preserving), then refactor internals. Do not attempt a sweep.
  • Existing 2.2.x consumers: treat 2.2.2 as a targeted upgrade, not a routine patch bump. Enumerate every class implementing ReadRepository (including test doubles) and add count/exists where required.

Compatibility

  • Runtime compatibility risk is concentrated in the interface expansion, not in the framework matrix.
  • Static analysis (PHPStan/Psalm at a high level) and IDE-generated mocks will surface breakage early — run these as the gate.
  • If the team pins via 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

  1. Pin the current version and capture a baseline test run.
  2. Review the two commits and the interface diff directly (the release notes alone are insufficient).
  3. Enumerate all ReadRepository implementers and test doubles; patch them.
  4. Upgrade in a branch with static analysis + full test suite as the gate.
  5. Adopt count/exists incrementally where they replace hand-rolled ->count() / ->exists() calls, keeping behavior identical.
  6. Exercise the pagination path with zero-result and zero/edge page-size inputs to confirm the division-by-zero fix.
  7. Only after validation, relax the pin and document the version rationale.

Operational Impact

Maintenance

  • Low ongoing maintenance surface: no migrations, no config, no background jobs, no external services. Upgrades are Composer-driven.
  • Ongoing cost is code-hygiene cost: keeping repository interfaces in sync as the domain evolves, and resisting the drift back to direct Eloquent calls in controllers.
  • Budget a recurring line item for dependency review — this package's release notes do not self-announce breaking changes, so version review must be manual.

Support

  • Community/open-source support model: GitHub issues and PRs only. No vendor SLA.
  • Given sparse release documentation, plan on reading commit diffs rather than changelogs. Assign a named owner for this dependency so review isn't ad hoc.
  • Validate maintainer responsiveness during evaluation; if the project is effectively single-maintainer, treat it as a medium-risk dependency and consider whether the abstraction is worth forking or inlining if it stalls.

Scaling

  • Application-level abstraction — scales with the app, imposes no independent scaling concern.
  • Performance is a function of what the repository emits, not the package: watch for N+1 queries, missing eager loads, and 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.
  • Under load, the repository layer adds negligible overhead versus the underlying query cost — but it can hide query shape, so pair adoption with query logging/APM on the extracted domains.

Failure modes

  • Interface drift (most likely): a future minor/patch adds a method and breaks implementers at deploy time — silent until the code path executes. Mitigate with exact pinning, interface-diff CI, and static analysis.
  • Pagination edge cases: the 2.2.2 division-by-zero fix implies at least one reachable arithmetic edge case existed in production paths. Re-test empty result sets, perPage = 0, and last-page boundaries.
  • Abstraction leakage: developers bypassing the repository for complex queries, producing two coexisting data-access styles and inconsistent testing.
  • Behavioral regression in the fix: if downstream code depended on the prior exception or on a specific empty-set result, the upgrade changes observable behavior.
  • Dependency abandonment: low-activity project leaves the team owning an unmaintained abstraction layer; exit cost is moderate (repository interfaces are portable, implementations are thin).

Ramp-up

  • Low for any Laravel developer: the pattern and package idioms are learnable in well under a day.
  • The real ramp is convention, not tooling: which aggregates get a repository, where criteria live, whether controllers may touch models, and how test doubles are structured. Write this down before rollout.
  • Pair the first repository extraction with a review checkpoint to establish the house pattern; subsequent extractions can proceed with less oversight.
  • Recommend a short internal note covering: the interface-expansion lesson from 2.2.2, the pinning policy, and the exists-over-count convention.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib