PHPackages                             fewagency/laravel-reformulator - 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. fewagency/laravel-reformulator

ActiveLibrary

fewagency/laravel-reformulator
==============================

Laravel middleware to filter, sanitize, parse and transform request input data.

5116PHP

Since Mar 20Pushed 7y ago2 watchersCompare

[ Source](https://github.com/bjuppa/laravel-reformulator)[ Packagist](https://packagist.org/packages/fewagency/laravel-reformulator)[ RSS](/packages/fewagency-laravel-reformulator/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Reformulator
============

[](#reformulator)

Laravel middleware to filter, sanitize, parse and transform request input data.

**Note:** I'd recommend using [Laravel's `FormRequest`s](https://laravel.com/docs/validation#form-request-validation)instead of this package's middleware if you wish to manipulate the incomming request before validation and other processing. Your intentions will be easier to understand if manipulation is done in your customized [`prepareForValidation()` method](https://github.com/laravel/framework/blob/master/src/Illuminate/Validation/ValidatesWhenResolvedTrait.php#L30-L38)of your `FormRequest` instead of hidden away in a middleware declared who knows where.

Also, since Laravel `5.4` there are already middleware for trimming strings and converting empty strings to `null` applied by default, so this package has been superfluous for quite some time.

Installation &amp; Configuration
--------------------------------

[](#installation--configuration)

> composer require fewagency/laravel-reformulator

Register each middleware you want to use in the `$routeMiddleware` array in `app/Http/Kernel.php` of your Laravel app:

```
'reformulator.trim' => \FewAgency\Reformulator\Middleware\TrimInput::class,
'reformulator.strip_repeats' => \FewAgency\Reformulator\Middleware\StripRepeatNonWordCharsFromInput::class,
'reformulator.filter' => \FewAgency\Reformulator\Middleware\FilterInput::class,

'reformulator.remove_empty' => \FewAgency\Reformulator\Middleware\RemoveEmptyInput::class,
'reformulator.clean_array' => \FewAgency\Reformulator\Middleware\CleanArrayInput::class,

'reformulator.concatenate' => \FewAgency\Reformulator\Middleware\ConcatenateInput::class,
'reformulator.explode' => \FewAgency\Reformulator\Middleware\ExplodeInput::class,

'reformulator.datetime-local' => \FewAgency\Reformulator\Middleware\DatetimeLocalInput::class,
'reformulator.datetime' => \FewAgency\Reformulator\Middleware\DatetimeInput::class,

```

Usage and parameters to each middleware is currently documented in [each of the classes](src/Middleware)but in general, most of them take a list of field names as middleware parameters.

Read more in the [Laravel docs for middleware](https://laravel.com/docs/middleware#registering-middleware).

Principles
----------

[](#principles)

Some would argue that it's **not** a good idea to mutate the `Request` object, for examples see [GrahamCampbell's comments on Laravel issue 10725](https://github.com/laravel/framework/issues/10725).

My opinion is that it makes sense to modify data in the request when:

- The same transformations *could* instead have been done on the client side before submitting, or substitutes a shortcoming in the transmission method (e.g. it's not possible to submit an empty array)
- The transformations absolutely can't go against the user's intention (as we're not giving the user a chance to approve the change)
- The transformations doesn't break repopulating the view (i.e. form)

Listen to [Full Stack Radio ep. 54 with Jonathan Reinink and host Adam Wathan](http://www.fullstackradio.com/54)for an interesting conversation about form handling. Adam then went on and created [a gist of macros to add filtering functions to Laravel `Request`s](https://gist.github.com/adamwathan/610a9818382900daac6d6ecdf75a109b).

Authors
-------

[](#authors)

I, Björn Nilsved, created this package while working at [FEW](http://fewagency.se).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![bjuppa](https://avatars.githubusercontent.com/u/5339269?v=4)](https://github.com/bjuppa "bjuppa (46 commits)")

---

Tags

laravel-middlewarerequest-transformation

### Embed Badge

![Health badge](/badges/fewagency-laravel-reformulator/health.svg)

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

PHPackages © 2026

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