complex-heart/criteria
Bring the Criteria pattern to Laravel Eloquent with complex-heart/criteria. Encapsulate query constraints in reusable, composable classes so filtering stays clean, testable, and out of your models. Ideal for flexible repository queries and complex search logic.
Adopt (or copy) when:
Look elsewhere — or write 100 lines yourself — when:
spatie/laravel-query-builder is purpose-built for that, vastly more adopted, and integrates with Laravel's request/validation idioms.Doctrine\ORM\Criteria is built in and better supported; don't layer a second abstraction over it.Given the low opportunity score, the realistic recommendation is: evaluate as a design reference, not a dependency. Read the source, adopt the interface shape, own the code.
For executives (one paragraph): This is a small, free, open-source PHP library that organizes "how we filter and search data" into reusable, named, testable pieces instead of copy-pasted database queries scattered across the codebase. It costs nothing to license and is quick to adopt, but it is a single-maintainer project with essentially no user base — so we would treat it as a pattern to adopt, not a vendor to depend on. Expected value is lower defect rates and faster delivery of filtering/search features; expected cost is roughly a week of engineering to introduce and migrate existing endpoints. Recommend a scoped pilot on one module, with the code vendored under our ownership.
For engineering leadership:
app/Domain/Criteria (MIT permits this) and add our own tests.spatie/laravel-query-builder (better for request-param filtering, not for domain-level reuse); Doctrine Criteria (built-in, only relevant if we move off Eloquent).How can I help you explore Laravel packages today?