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

Laravel Natural Where Laravel Package

jord-jd/laravel-natural-where

Adds natural-language where methods to Laravel's query builder and Eloquent, so you can write readable filters like whereName(), whereAgeGreaterThan(), and whereCreatedAtAfter() instead of verbose operator-based clauses.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit The package sits as a thin macro layer over Illuminate\Database\Query\Builder, exposing natural-language WHERE composition (naturalOrWhere implies a sibling naturalWhere). This is the lowest-coupling extension point Laravel offers: no service container bindings to manage, no facade to shadow, no config publishing required, and it degrades to a composer remove if it disappoints. Blast radius is confined to the queries that explicitly call the macro. For a TPM, that is an attractive risk profile — this is a convenience API, not infrastructure.

The one architectural signal worth flagging is the version span. A single release claiming Laravel 5.6 through Laravel 13 covers roughly seven years of framework evolution, including the transition from PHP 7.1 to a PHP 8.4-era floor. That is only achievable with loose illuminate/* constraints and defensive conditionals, which means the package is asserting compatibility it almost certainly cannot uniformly test. Nominal support is not the same as verified support.

Integration feasibility High, mechanically. Standard composer require, package discovery registers the provider, macros become available on the query builder globally. No migration, no schema, no queue worker or scheduler involvement, no published assets. A developer can be productive on day one.

The friction is in verification, not installation. Because the macro mutates query state rather than returning a value the developer inspects, an incorrect macro is invisible until someone reads the generated SQL or notices a wrong result set.

Technical risk Three items, in descending severity:

  1. The bug fix is the headline, and that is concerning. naturalOrWhere was not returning the builder result. In Laravel, a macro that fails to return the builder breaks fluent chaining and, worse, can silently drop the constraint from the composed query. A defect of this class produces broader result sets rather than an exception — meaning filtered views, exports, or scoped listings may have been returning rows they should have excluded. The fact that it shipped and persisted indicates the or variant of the macro had weak or absent test coverage relative to the and variant. Assume other unexercised branches exist in the natural-language parsing path.
  2. Version-span credibility. Supporting 5.6 and 13 from one branch implies either an enormous CI matrix or, more likely, untested claims at the edges. Since most consumers are on 10–11 today, the practical risk is low — but do not treat "supports 5.6" as evidence of rigor.
  3. Input handling. "Natural" WHERE clauses imply string parsing. If the macro interpolates values rather than binding parameters, every call site is an injection vector. This is the single question that determines whether the package is acceptable.

Key questions

  • Does the macro bind parameters, or interpolate them into the SQL string?
  • What is the exact grammar accepted by the natural-language parser, and what happens on unparseable input — exception, silent drop, or pass-through?
  • What PHP version does composer.json require, and does that floor conflict with the app?
  • Is the naturalOrWhere return-value fix behavior-changing for existing callers who may have worked around it?
  • What does the CI matrix actually cover — every claimed Laravel version, or only the endpoints?
  • Are macro names namespaced to avoid collision with other packages registering query builder macros?

Integration Approach

Stack fit Compatible with any Laravel application on the supported range, which in practice means every reasonably current codebase. It is framework-idiomatic and requires no deviation from standard Laravel conventions. For teams already using query builder macros for other concerns, verify naming collisions before adoption — macros share a single global namespace on the builder.

Migration path This is an additive, patch-level adoption. No data migration, no config transition, no dual-write period. The only migration-shaped concern is the defect being fixed: if any existing code depended on naturalOrWhere's prior non-returning behavior — for example, invoking it as a terminal statement and then reassigning $query — that code may need a one-line review. In a greenfield adoption this is moot.

Compatibility The version span is the item needing active validation rather than passive trust. Pin to a known-good minor, confirm the package's PHP floor against the application's runtime, and treat the Laravel 5.6 claim as documentation rather than a tested guarantee. Note that Laravel 5.6 left security support in 2019; retaining compatibility is a courtesy to legacy consumers, not a signal that the legacy path is exercised.

Sequencing

  1. Adopt in a non-production environment only.
  2. Enable query logging and capture generated SQL for every call site before and after.
  3. Diff the captured SQL against the equivalent hand-written where/orWhere clauses to confirm predicate equivalence — this is the step that catches silent constraint loss.
  4. Add regression tests at your call sites specifically covering the or composition path, given the disclosed defect.
  5. Roll to production; keep the query log review in place for one release cycle.

Operational Impact

Maintenance Ongoing cost to the adopting team is near zero — no configuration to drift, no schema to migrate, no runtime dependency to keep warm. The maintenance burden sits with the maintainer, and the broad version matrix is a proxy for how much of that burden is being absorbed versus deferred. Watch release cadence: a package that supports seven major framework versions tends to ship infrequently and in large batches, which concentrates upgrade risk.

Support Small surface area, but the support conversation is unusually SQL-literate. When something misbehaves, the first diagnostic is the query log, not the stack trace. Teams without a habit of inspecting generated SQL will find this package harder to debug than its simplicity suggests. Ensure at least one engineer can read the emitted SQL fluently.

Scaling The macro executes at query-construction time, so per-request overhead is proportional to the number of filter clauses, not to data volume. Negligible in normal use. The scaling risk is indirect: if natural-language clauses are assembled from user-supplied filter parameters, an unbounded parameter set translates into an unbounded predicate count and a query planner worst case. Bound the accepted filter surface at the application layer regardless of what the package permits.

Failure modes

  • Silent constraint loss (the class of bug just fixed): the macro fails to return the builder, the predicate is dropped, the query returns a superset of intended rows. Highest severity because it is invisible and errs toward over-exposure in filtered views and exports.
  • Parse failure on unexpected input: depending on design, may throw, may silently no-op, or may pass input through. Each has a different operational consequence; confirm which applies before exposing the macro to user-controlled input.
  • Injection via interpolation: if values are not bound, treat every call site as untrusted.
  • Macro collision: a second package registering the same macro name silently overrides, with behavior differing by load order.

Ramp-up Hours, not days. A developer needs the DSL grammar, the knowledge that the macro returns the builder and must therefore participate in the chain, and the habit of checking the query log. Document the accepted grammar and one canonical example per call site; that is sufficient onboarding for a team of any size.

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.
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin
artisan-build/community-prompts
vleroy/smart
ayles-software/laravel-australian-public-holidays
cboxdk/laravel-id-spatie
cboxdk/laravel-id-billing
cboxdk/laravel-id-billing-bridge
simple-as-fuck/php-performance-log
hsluv/hsluv
seampact/codegen