yuriitatur / search
A simple framework/db agnostic api search package
v1.0.0
2025-08-09 21:33 UTC
Requires
- php: >=8.2
- yuriitatur/repository: dev-master
Requires (Dev)
- dg/bypass-finals: ^1.9
- jms/serializer: ^3.32
- kint-php/kint: ^6.0
- league/fractal: ^0.20.2
- phpunit/phpunit: ^12.0
- symfony/property-access: ^7.3
- symfony/serializer: ^7.3
- symfony/validator: ^7.0
Suggests
- jms/serializer: Allows you to use JmsSerializerCursorHydrator
- symfony/property-access: Allows you to use ProperyAccessCursorHydrator
- symfony/serializer: Allows you to use SymfonySerializerCursorHydrator
This package is auto-updated.
Last update: 2025-08-09 21:34:20 UTC
README
Search module
A simple module to validate and query your api.
Installation
Composer:
composer require yuriitatur/search
Usage
class PageFilter implements FilterInterface
{
public function applyFilter(QueryBuilder $builder, $value): array
{
$builder
->limit(10)
->offset(((int)$value - 1) * 10);
}
public function getValidationRules(): array
{
return [
new Interger(),
new GreaterThan(0),
];
}
}
$seeker = new Seeker(
new RequestValidator(Validation::createValidator()),
new QueryComposer,
new PaginatorQueryExecutor($repository),
DefaultFilters::get([
'page' => new PageFilter
])
);
$result = $seeker->seek([
'page' => 2
]);
Testing
composer test
License
This code is under MIT license, read more in the LICENSE file.