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)0690↓86.7%1GPL-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 3d 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

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

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

823d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39025147?v=4)[Benediktas Rukas](/maintainers/benycode)[@benycode](https://github.com/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

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

173229.0k3](/packages/davidepastore-slim-validation)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k39](/packages/neuron-core-neuron-ai)[slim/csrf

Slim Framework 4 CSRF protection PSR-15 middleware

3732.2M103](/packages/slim-csrf)[slim/http-cache

Slim Framework HTTP cache middleware and service provider

1243.1M33](/packages/slim-http-cache)

PHPackages © 2026

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