maartenpaauw/laravel-specification-pattern
A Laravel package for the specification pattern, letting you encapsulate business rules into reusable, composable specifications and apply them to Eloquent queries or collections for cleaner, testable domain logic.
and/or/not operators, so you can ship new filter combinations on the roadmap without rewriting query logic. Maps well to features like "advanced filtering" or "saved segments."Consider it when:
Look elsewhere when:
spatie/laravel-query-builder, or dedicated query packages; this package does not build SQL.For executives: A small MIT-licensed utility that standardizes how we filter data in code. It lets us ship filter features faster and keeps business rules consistent and testable, reducing bug surface. The footprint is tiny and reversible — low cost, low lock-in. Main watch-item: the project is community-maintained with a small user base, so we should pilot it and pin the version before wider rollout.
For engineering: It applies the classic specification pattern to Laravel collections, giving named, composable (and/or/not), unit-testable filter objects instead of scattered conditionals. Best suited to in-memory filtering (cached/API/imported data); pair with Eloquent scopes for DB-level work. The API is small and readable, MIT-licensed, and actively released. Caveat: low stars/adoption — evaluate first and consider wrapping it behind our own interface to contain dependency risk.
How can I help you explore Laravel packages today?