arodu / cakephp-query-filter
Declarative query filtering for CakePHP index actions
Package info
github.com/arodu/cakephp-query-filter
Type:cakephp-plugin
pkg:composer/arodu/cakephp-query-filter
v3.0.1
2026-10-16 23:27 UTC
Requires
- php: >=8.2
- cakephp/cakephp: ^5.0
Requires (Dev)
- cakephp/cakephp-codesniffer: ^5.0
- phpunit/phpunit: ^10.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-17 11:56:33 UTC
README
Declarative query filtering for CakePHP index actions. Map form input keys to table finders and apply them to a query in a single call, keeping controllers free of filter plumbing.
Requirements
- PHP >= 8.2
cakephp/cakephp^5.0
Installation
composer require arodu/cakephp-query-filter:^3.0
Load the plugin in src/Application.php:
$this->addPlugin(\QueryFilter\QueryFilterPlugin::class);
Quick start
// In the table's initialize() (or a setup method) $this->addBehavior('QueryFilter.QueryFilter', [ 'filterFields' => [ 'name' => ['tableField' => 'name', 'finder' => \QueryFilter\QueryFilter::FINDER_STRING], 'status' => ['tableField' => 'status', 'finder' => \QueryFilter\QueryFilter::FINDER_SELECT], ], ]); // In the controller action $behavior = $this->Students->getBehavior('QueryFilter'); $query = $behavior->queryFilter($this->Students->find(), $this->request->getQuery('f') ?? []);
Documentation
- Usage — registering filters and applying them.
- Finders reference — every finder, its arguments and examples.
- Templates — building field/value conditions.
- Events —
beforeFilter,afterFilter,beforeFinder,afterFinder.
License
MIT