PHPackages                             onvardgmbh/laravel-filters - 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. onvardgmbh/laravel-filters

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

onvardgmbh/laravel-filters
==========================

Filters for Laravel &gt;=5.2

1.2.1(10y ago)0227MITPHPPHP &gt;=5.6.0

Since Feb 19Pushed 10y ago2 watchersCompare

[ Source](https://github.com/onvardgmbh/laravel-filters)[ Packagist](https://packagist.org/packages/onvardgmbh/laravel-filters)[ RSS](/packages/onvardgmbh-laravel-filters/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

Laravel &gt; 5.2 Route Filter
=============================

[](#laravel--52-route-filter)

1) Register the FilterServiceProvider
-------------------------------------

[](#1-register-the-filterserviceprovider)

Add the following to your `config/app.php`.

```
return [

    . . .

    /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => [

        . . .

        /*
         * The FilterServiceProvider needs to be inserted BEFORE App\Providers\RouteServiceProvider::class,
         */
        Onvard\Filter\FilterServiceProvider::class,

        App\Providers\RouteServiceProvider::class,
    ],

    . . .

];
```

2) Adding the Middleware
------------------------

[](#2-adding-the-middleware)

Add the `filter` Middleware to `middlewareGroups` and `routeMiddleware` in `app/Http/Kernel.php`.

```
. . .

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
        ],

        'api' => [
            'throttle:60,1',
        ],

        'filter' => [
            \Onvard\Filter\Middleware\ApplyFilters::class,
        ],

. . .

    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'filter' => \Onvard\Filter\Middleware\ApplyFilters::class,
    ];

. . .
```

3) Publish the Provider
-----------------------

[](#3-publish-the-provider)

Execute:

```
php artisan vendor:publish --provider="Onvard\Filter\FilterServiceProvider" --tag=filters

```

If the Provider doesn't get recognized, you maybe need to run `php artisan clear:config` and run it again.

4) Using the Middleware
-----------------------

[](#4-using-the-middleware)

This is an Example of 'How To Use' the Middleware.

The first Example shows the Usage of the `minifyHTML` Filter for a `Route::group` to minify the HTML Output after it is generated.

The second Example shows the Usage of the `functionName` Filter for a single `Route` before and after it is requested.

```
. . .

Route::group(['middleware' => ['web','filter'], 'filter' => [ 'after' => [ 'minifyHTML' ] ] ],function () {
    Route::get( '/',
        [
            'middleware' => ['filter'],
            'filter' => [
                'before' => [
                    'functionName'
                ],
                'after' => [
                    'functionName'
                ]
            ],
            function () {
                return view('welcome');
            }
        ]
    );
});

. . .
```

5) Adding more Filters
----------------------

[](#5-adding-more-filters)

You can find Filters in `app/Filters/Filter.php` and add what you need.

If a Filter doesn't get recognized, you maybe need to run `php artisan clear-compiled` and `php artisan optimize`.

LICENSE
=======

[](#license)

[MIT LICENSE](LICENSE)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~1 days

Total

4

Last Release

3777d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/42c1421a388c5cbfe041a2cf4e19386d1f38407463fed211c35e24db4cbed5ed?d=identicon)[onvardgmbh](/maintainers/onvardgmbh)

---

Top Contributors

[![AndreSchwarzer](https://avatars.githubusercontent.com/u/6991100?v=4)](https://github.com/AndreSchwarzer "AndreSchwarzer (4 commits)")[![bjoernhasse](https://avatars.githubusercontent.com/u/16560273?v=4)](https://github.com/bjoernhasse "bjoernhasse (3 commits)")

---

Tags

laravelfilterfilters

### Embed Badge

![Health badge](/badges/onvardgmbh-laravel-filters/health.svg)

```
[![Health](https://phpackages.com/badges/onvardgmbh-laravel-filters/health.svg)](https://phpackages.com/packages/onvardgmbh-laravel-filters)
```

###  Alternatives

[millat/laravel-hooks

The WordPress filter, action system in Laravel

5717.0k](/packages/millat-laravel-hooks)

PHPackages © 2026

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