PHPackages                             alifcoder/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. [Search &amp; Filtering](/categories/search)
4. /
5. alifcoder/query-filter

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

alifcoder/query-filter
======================

A clean query filter builder for Laravel

v1.0.4(1y ago)022MITPHPPHP &gt;=8.2

Since May 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/alifcoder/query-filter)[ Packagist](https://packagist.org/packages/alifcoder/query-filter)[ RSS](/packages/alifcoder-query-filter/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (2)Versions (6)Used By (0)

🔍 Alif Query Filter
===================

[](#-alif-query-filter)

A lightweight, clean, and reusable query filtering library for Laravel Eloquent models — built to help you keep your controllers clean and your queries dynamic.

---

✨ Features
----------

[](#-features)

- Chainable, dynamic Eloquent filtering based on request input
- Filters as separate classes — fully testable and reusable
- Simple base class for filters
- Works out-of-the-box with Laravel
- Publishable config

---

📦 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- Laravel ^11.0 || ^12.0

---

🚀 Installation
--------------

[](#-installation)

```
composer require alifcoder/query-filter
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Publish the config (optional):

```
php artisan vendor:publish --tag=query-filter-config
```

You can configure default filter namespace or behavior.

---

🧱 Usage
-------

[](#-usage)

### 1. Create a Filter

[](#1-create-a-filter)

```
php artisan make:filter StatusFilter
```

### 2. Define the logic

[](#2-define-the-logic)

```
// app/Filters/StatusFilter.php
use Alif\QueryFilter\Contracts\Filter;

class StatusFilter implements Filter
{
    public function handle(Builder $query, $value, Closure $next)
    {
        if ($value) {
            $query->where('status', $value);
        }

        return $next($query);
    }
}
```

### 3. Use in your model or controller

[](#3-use-in-your-model-or-controller)

```
use Alif\QueryFilter\QueryFilter;

$filtered = Post::filter(QueryFilter::make([
    'status' => request('status'),
    'sort' => request('sort'),
]))->get();
```

---

🌐 Example Query
---------------

[](#-example-query)

```
GET /posts?status=published&sort=created_at
```

---

🧩 Folder Structure
------------------

[](#-folder-structure)

```
src/
├── Contracts/
│   └── Filter.php
├── Filters/
│   └── QueryFilter.php
├── QueryFilterServiceProvider.php
config/
└── query-filter.php

```

---

📜 License
---------

[](#-license)

MIT © [Shukhratjon Yuldashev](https://t.me/alif_coder)

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance49

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

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

Every ~8 days

Total

5

Last Release

375d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/94315908?v=4)[Shukhrat Yuldashev](/maintainers/alifcoder)[@alifcoder](https://github.com/alifcoder)

---

Top Contributors

[![iamshukhrat](https://avatars.githubusercontent.com/u/61014049?v=4)](https://github.com/iamshukhrat "iamshukhrat (3 commits)")

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)

PHPackages © 2026

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