PHPackages                             ralphschindler/basic-query-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ralphschindler/basic-query-filter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ralphschindler/basic-query-filter
=================================

Basic Query Filter

0.1.0(9y ago)145.8k↓48.3%22PHP

Since Mar 28Pushed 9y agoCompare

[ Source](https://github.com/ralphschindler/basic-query-filter)[ Packagist](https://packagist.org/packages/ralphschindler/basic-query-filter)[ RSS](/packages/ralphschindler-basic-query-filter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (2)

Basic Query Filter
==================

[](#basic-query-filter)

This started out as a weekend-project. A DSL Parser for a filter query langague that primarily can be used in an API or similar setting where filtering is based on predicate logic.

The goal is to be able to take string filters and parse them into predicate expression objects in order to adjoin them to a backend implementation. This backend implementation could be Doctrine, Laravel Eloquent, or document storage.

Example queries in this language:

- `price > 100`
- `price > 100 AND active = 1`
- `product.price > 100 AND category.id = 7`
- `name =~ "Foo%"`
- `created_at > "2017-01-01" and created_at < "2017-01-31"`
- `status = 1 AND (name = "PHP Rocks" || name = "I ♥ API's")`

Install
-------

[](#install)

```
composer require "ralphschindler/basic-query-filter"

```

Usage
-----

[](#usage)

Basic usage is to take a string and parse it, using the ParseTree to be able to convert the expressions to whatever is required by the library you are adjoining.

```
$parseTree = (new QueryFilter\Parser)->parse($filter);
foreach ($parseTree->getPredicates() as $predicateInfo) {
    list($combinedBy, $predicate) = $predicateInfo;
    // ...
}
```

### Laravel

[](#laravel)

Expand usage as necessary to accommodate more filtering features.

```
// $modelQuery is a Model::newQuery() instance (Illuminate\Database\Eloquent\Builder)

foreach ($parseTree->getPredicates() as $predicateInfo) {
    list($combinedBy, $predicate) = $predicateInfo;
    $op = ($predicate->op == '=~') ? 'like' : $predicate->op;
    if ($combinedBy === 'OR') {
        $modelQuery->orWhere((string)$predicate->left, $op, $predicate->right);
    } else {
        $modelQuery->where((string)$predicate->left, $op, $predicate->right);
    }
}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3338d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c4a15cb4e97bc39a3aea8304fb04d56c0d753f2a6b79c83db0a894647ba8de7?d=identicon)[ralphschindler](/maintainers/ralphschindler)

---

Top Contributors

[![ralphschindler](https://avatars.githubusercontent.com/u/76674?v=4)](https://github.com/ralphschindler "ralphschindler (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ralphschindler-basic-query-filter/health.svg)

```
[![Health](https://phpackages.com/badges/ralphschindler-basic-query-filter/health.svg)](https://phpackages.com/packages/ralphschindler-basic-query-filter)
```

PHPackages © 2026

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