PHPackages                             benycode/slim-request-validation - 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. [Framework](/categories/framework)
4. /
5. benycode/slim-request-validation

ActiveLibrary[Framework](/categories/framework)

benycode/slim-request-validation
================================

A slim middleware for HTTP request validation based on Respect/Validation

v1.4.8(2y ago)0645↓33.3%GPL-2.0+PHPPHP ^7.4 || ^8.0

Since Nov 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/benycode/slim-request-validation)[ Packagist](https://packagist.org/packages/benycode/slim-request-validation)[ RSS](/packages/benycode-slim-request-validation/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (20)Used By (0)

Slim Framework Request Validation
=================================

[](#slim-framework-request-validation)

A **Request** validation library for the Slim 4 Framework. It uses [respect-validation](https://github.com/Respect/Validation) library.

Table of contents
-----------------

[](#table-of-contents)

- [Install](#install)
- [Usage](#usage)

Install
-------

[](#install)

Via Composer

```
$ composer require benycode/slim-request-validation
```

Requires Slim 4.

Usage
-----

[](#usage)

Create a **Rule** class:

```
use BenyCode\Slim\Validation\Rule\RequestValidationRuleInterface;
use Respect\Validation\Validator;

final class AnyRuleClass implements RequestValidationRuleInterface
{
    public function rules(): array
    {
        return [
          'name' => Validator::alpha(),
          'url' => Validator::filterVar(FILTER_VALIDATE_URL),
        ];
    }

    public function messages(): array
    {
        return [
            'filterVar' => '{{name}} must be valid modified message.',
        ];
    }
}
```

add a **Middlewares** to route:

```
use BenyCode\Slim\Validation\Middleware\RequestValidationExceptionMiddleware;
use BenyCode\Slim\Validation\Transformer\RequestValidatorTransformFactory;
use BenyCode\Slim\Validation\Encoder\JsonEncoder;

$app = new \Slim\App();

$app->post('/api/any_end_point',function ($req, $res, $args) {

})
->add(new RequestValidationExceptionMiddleware(new RequestValidatorTransformFactory(), new JsonEncoder()))
->add(new RequestValidation([
	new AnyRuleClass(),
]))
;

$app->run();
```

keep a clean code and split the rules:

```
use BenyCode\Slim\Validation\Middleware\RequestValidationExceptionMiddleware;
use BenyCode\Slim\Validation\Transformer\RequestValidatorTransformFactory;
use BenyCode\Slim\Validation\Encoder\JsonEncoder;

$app = new \Slim\App();

$app->post('/api/any_end_point',function ($req, $res, $args) {

})
->add(new RequestValidationExceptionMiddleware(new RequestValidatorTransformFactory(), new JsonEncoder()))
->add(new RequestValidation([
	new AnyRuleClass(),
	new AppendedRuleClass(),
	new AppendedRule2Class(),
	new AppendedRule3Class(),
	....
]))
;

$app->post('/api/any_end_point2',function ($req, $res, $args) {

})
->add(new RequestValidationExceptionMiddleware(new RequestValidatorTransformFactory(), new JsonEncoder()))
->add(new RequestValidation([
	new AnyRuleClass(),
	new AppendedRule3Class(),
	....
]))
;

$app->run();
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

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 ~48 days

Recently: every ~0 days

Total

19

Last Release

775d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cb3e8d371d500a222cf7d259a737b7de87389296eb9584360f9a68c594d2a2dc?d=identicon)[benycode](/maintainers/benycode)

---

Top Contributors

[![benycode](https://avatars.githubusercontent.com/u/39025147?v=4)](https://github.com/benycode "benycode (33 commits)")

---

Tags

requestmiddlewareframeworkvalidatorvalidationslim

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/benycode-slim-request-validation/health.svg)

```
[![Health](https://phpackages.com/badges/benycode-slim-request-validation/health.svg)](https://phpackages.com/packages/benycode-slim-request-validation)
```

###  Alternatives

[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)[cakephp/cakephp

The CakePHP framework

8.8k18.5M1.6k](/packages/cakephp-cakephp)[slim/csrf

Slim Framework 4 CSRF protection PSR-15 middleware

3512.1M94](/packages/slim-csrf)[slim/http-cache

Slim Framework HTTP cache middleware and service provider

1242.9M27](/packages/slim-http-cache)[bnf/slim3-psr15

PSR-15 middleware support for Slim Framework v3

10177.0k5](/packages/bnf-slim3-psr15)[davidepastore/slim-restrict-route

A Slim middleware to restrict ip addresses that will access to your routes

2220.6k1](/packages/davidepastore-slim-restrict-route)

PHPackages © 2026

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