PHPackages                             vdhicts/data-filter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. vdhicts/data-filter

AbandonedArchivedLibrary[Search &amp; Filtering](/categories/search)

vdhicts/data-filter
===================

Easily filter data with an encoded filter param in the uri

1.6.3(8y ago)0203MITPHP

Since Jun 27Pushed 4y agoCompare

[ Source](https://github.com/vdhicts/data-filter)[ Packagist](https://packagist.org/packages/vdhicts/data-filter)[ RSS](/packages/vdhicts-data-filter/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (16)Used By (0)

Data-filter
===========

[](#data-filter)

Easily filter data with an encoded filter param in the uri.

Requirements
------------

[](#requirements)

This package requires PHP 5.6+.

Installation
------------

[](#installation)

This package can be used in any PHP project or with any framework. The package is tested in PHP 5.6 and PHP 7.0.

You can install the package via composer:

```
composer require vdhicts/data-filter

```

Usage
-----

[](#usage)

### Filter Field

[](#filter-field)

Creating field is based on a key and a value:

```
$fieldKey = 'manufacturer';
$fieldValue = 1;

$field = new Field($fieldKey, $fieldValue);
```

A field has the ability to accept, reject or see the value as part of a range with a third optional parameter. These parameters are constants of the field `APPROVAL_ACCEPT`, `APPROVAL_REJECT`, `APPROVAL_START_OF_RANGE`, `APPROVAL_END_OF_RANGE`, `APPROVAL_IN`, `APPROVAL_NOT_IN`, `APPROVAL_LIKE` and `APPROVAL_ILIKE` (which can only be used if your Database supports it, like Postgres).

### Filter Group

[](#filter-group)

The field is a member of a group. The group has a conjunction, which are constants of the group called `CONJUNCTION_AND` and `CONJUCTION_OR`.

```
$group = new Group('manufacturers', $field, Group::CONJUNCTION_OR);
```

One or more groups are provided to the filter:

```
$filter = new Filter([$group]);
```

### Order

[](#order)

The sort order can be defined by `OrderField` objects:

```
$orderField = new Orderfield('myField', 'ASC');
```

These objects are added to the order:

```
$order = new Order([$orderField2]);
```

### Pagination

[](#pagination)

The pagination is handled by the `Pagination` object:

```
$limit = 50;
$offset = 10;
$pagination = new Pagination($limit, $offset);
```

The remove the limit, use the `NO_LIMIT` constant from the `Pagination` class. By default no limit is used and the offset is zero.

### Manager

[](#manager)

The manager can encode and decode the filter so it can be used in the url or session. The actual encoding or decoding is performed by a `Codec` which implements the `Codec` contract. By default a `Base64` codec is provided.

```
$manager = new Manager(new Base64());
$encodedFilter = $manager->encode($filter);
```

The manager can decode the filter and will return a new filter instance:

```
$decodedFilter = $manager->decode($encodedFilter);
```

A group can be retrieved by it's name from the filter:

```
$decodedFilter->getGroup('manufacturers');
```

Which will return a `Group` object.

Fields can also be retrieved by their key from the group:

```
$group->getFields('manufacturer');
```

Which will return an array of groups.

### Adapter

[](#adapter)

A query builder is provided to easily query your database with the filter configuration for the illuminate query builder:

```
$filterAdapter = new QueryBuilder();

$queryBuilder = $filterAdapter->getFilterQuery($queryBuilder, $decodedFilter);
return $queryBuilder->get();
```

You are free to implement your own adapter, as long as it implements the `FilterAdapter` contract.

Tests
-----

[](#tests)

Full code coverage unit tests are available in the tests folder. Run via phpunit:

`vendor\bin\phpunit`

By default a coverage report will be generated in the build/coverage folder.

Contribution
------------

[](#contribution)

Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request per feature. In exchange you will be credited as contributor on this page.

Security
--------

[](#security)

If you discover any security related issues in this or other packages of Vdhicts, please email  instead of using the issue tracker.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

About vdhicts
-------------

[](#about-vdhicts)

[Van der Heiden ICT services](https://www.vdhicts.nl) is the name of my personal company for which I work as freelancer. Van der Heiden ICT services develops and implements IT solutions for businesses and educational institutions.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~49 days

Total

15

Last Release

2969d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/88d23e7b707d1cfe0eea91c00590613f45e0c75cb0a3ce89354328332e5c0c02?d=identicon)[vdhicts](/maintainers/vdhicts)

---

Top Contributors

[![dvdheiden](https://avatars.githubusercontent.com/u/90568118?v=4)](https://github.com/dvdheiden "dvdheiden (15 commits)")

---

Tags

data-filteringphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vdhicts-data-filter/health.svg)

```
[![Health](https://phpackages.com/badges/vdhicts-data-filter/health.svg)](https://phpackages.com/packages/vdhicts-data-filter)
```

###  Alternatives

[awesome-nova/dependent-filter

Dependent filters for Laravel Nova

26193.1k](/packages/awesome-nova-dependent-filter)[algolia/php-dom-parser

A simple tool to turn DOM into Algolia search friendly record objects.

181.8k](/packages/algolia-php-dom-parser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
