myerscode/laravel-query-strategies
myerscode/laravel-query-strategies provides reusable, composable query strategies for Laravel Eloquent models, helping you encapsulate filtering, sorting, and search logic to keep controllers clean and queries testable.
Architecture fit
myerscode/laravel-query-strategies sits in the request-to-Eloquent seam of a Laravel API: HTTP query parameters are mapped to a declarative Strategy → Parameter → Clause pipeline that composes filters, sorts, includes, and pagination onto a query builder. This is architecturally attractive for teams operating many REST/JSON:API endpoints, because it centralises ad-hoc ->when($request->has(...)) logic into named, testable, reusable strategies. The 13.0.0 feature set materially broadens that fit: relationship filtering, nested relationship sorting, aggregate relationship includes, field selection, ScopeClause for model scopes, TrashedClause for soft deletes, and BetweenClause for ranges cover the majority of realistic list-endpoint requirements without bespoke code.
Integration feasibility
Composer-installable with a conventional service-provider/config-publish flow. The release targets Laravel 13 and Testbench 11, which is the dominant feasibility gate — adoption is effectively tied to running Laravel 13 (or a narrow adjacent range). Test coverage improvements, Rector modernisation, and Larastan level 8 compliance are positive signals of engineering hygiene and reduce the "abandoned package" risk. The Parameter readonly conversion and StrategyManager instantiation fix indicate internal contracts were tightened, which is good for stability but hostile to anyone who extended internals.
Technical risk
This is a 0-to-13.0.0 jump with no prior assessment, and a major version bump plus "update to Laravel 13" almost certainly signals dropped support for earlier Laravel/PHP versions and at least one breaking change for custom strategies/parameters. Specific risks: (1) Parameter being readonly breaks any code that mutates parameters post-construction; (2) the StrategyManager double-instantiation and "cached compiled defaultMethods map" changes can alter resolution order or side-effect timing for custom strategies; (3) the eager-load validation fix and strict-mode addition mean previously accepted (and silently ignored or exploited) input now behaves differently — a behavioural, not just API, break; (4) "filter shorthand for clause class" and callback/inline filters introduce user-adjacent dynamic query construction, so strict mode should be treated as a security control, not a convenience toggle. Overall risk is moderate: high blast radius if adopted as the primary query layer, but mitigable via staged rollout and strict mode.
Key questions
illuminate/* and PHP version constraints, and is there a maintenance branch for Laravel 11/12?Stack fit Strong fit for a Laravel 13 API-first application or a monolith with a public/partner API surface. Weaker fit where query semantics are highly bespoke, where the GraphQL/API-platform layer already owns filtering, or where a DBA-owned reporting layer expects raw SQL. The package's vocabulary (strategies, parameters, clauses) maps cleanly onto an API platform team's mental model and gives the TPM a legible artefact for API contracts — each strategy is effectively a documented, versionable endpoint specification.
Migration path
Since there is no incumbent assessment, treat this as greenfield. Two lanes: (a) if the estate is already on Laravel 13, adopt 13.0.0 directly in a non-critical service and pin exactly (13.0.*) until the changelog has been read end-to-end; (b) if on Laravel 11/12, do not upgrade Laravel 13 to reach this package — instead identify the last 12.x tag, or defer adoption until the framework upgrade is independently justified. For teams that prototyped earlier versions, budget explicit rework for any custom Parameter subclasses (readonly) and any reliance on prior eager-load leniency.
Compatibility
Requires Laravel 13 / Testbench 11 alignment and the PHP floor implied by the Rector modernisation (assume modern PHP; verify composer.json). Compatibility risk concentrates in third-party packages that pin older illuminate/support, and in any in-house traits that monkey-patch StrategyManager.
Sequencing
Maintenance Low ongoing code maintenance (declarative config replaces repetitive controller logic) but non-trivial version maintenance: a package that jumps to a new major aligned with each Laravel major means a recurring, calendar-driven upgrade task. Recommend tracking releases and assigning an owner; pinning minor versions is essential. The Rector/Larastan work means formatting churn between versions is likely, so expect diff noise on upgrade.
Support Community/maintainer-driven, not vendor-backed. Acceptable for internal tooling; for a customer-facing API with SLAs, require either an internal fork capability or a documented fallback to hand-written query scopes. The level-8 static analysis and improved test coverage are reasonable proxies for supportability, but they are not a support contract.
Scaling
Performance work in this release is directly relevant to scaling: caching the compiled defaultMethods map removes per-request reflection, direct clause instantiation and replacing collect() with array operations reduce allocation on hot list endpoints, and removing the redundant limit() before paginate() avoids a class of count/limit bugs. Net effect is favourable for high-QPS read endpoints, provided strict mode and eager-load validation are on — those are also the primary defence against clients constructing pathological queries (deep relationship includes, unbounded sorts).
Failure modes
Ramp-up Engineers familiar with Eloquent will onboard in roughly a sprint; the conceptual load is the three-layer vocabulary plus the strategy registration/config conventions, not the underlying ORM. The main ramp-up cost is organisational: agreeing the strategy catalogue, naming, and allowed-parameter policy is a design exercise that should be owned by the TPM/API owner, not left to individual endpoint authors. Budget documentation work for the strategy catalogue — it doubles as the public API contract and is the highest-leverage artefact for reducing support load.
How can I help you explore Laravel packages today?