PHPackages                             markuper/sanitizer - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. markuper/sanitizer

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

markuper/sanitizer
==================

1.1.0(5mo ago)0210↓100%MITPHPPHP &gt;=5.3.0

Since May 22Pushed 5mo agoCompare

[ Source](https://github.com/thebuddha/sanitizer)[ Packagist](https://packagist.org/packages/markuper/sanitizer)[ RSS](/packages/markuper-sanitizer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (7)Used By (0)

[![Travis Status](https://camo.githubusercontent.com/f3b654b3dd6f3b563ec599e868fa5be0d324c4154ce88ea28ad57e1648f848b7/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/f3b654b3dd6f3b563ec599e868fa5be0d324c4154ce88ea28ad57e1648f848b7/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)[![Github Release](https://camo.githubusercontent.com/aafb4472a4896e44d5ac6f9eecaeddfca1b7a03d6943c3488ef797195db00b44/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/aafb4472a4896e44d5ac6f9eecaeddfca1b7a03d6943c3488ef797195db00b44/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)[![Packagist License](https://camo.githubusercontent.com/938acf50daa0c3cd181149e648c3dde041d4a59c2e2bf0f8a54d50c47e4a7063/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/938acf50daa0c3cd181149e648c3dde041d4a59c2e2bf0f8a54d50c47e4a7063/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)[![Packagist Downloads](https://camo.githubusercontent.com/10933d55cd57eb0f4bbb0ed1639bb20a3d3d54e356afadf96b572033d906bc79/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/10933d55cd57eb0f4bbb0ed1639bb20a3d3d54e356afadf96b572033d906bc79/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)[![Github Issues](https://camo.githubusercontent.com/b1e04f10cbadaade011cf802bc37b4077f42b0d9c98f6df2f792edb57db39518/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/b1e04f10cbadaade011cf802bc37b4077f42b0d9c98f6df2f792edb57db39518/687474703a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6461796c65726565732f73616e6974697a65722e7376673f7374796c653d666c61742d737175617265)[![Tips](https://camo.githubusercontent.com/880e72136c8cab83257e464146cfea1798d3f1382cf8fe4f40c655743a875439/687474703a2f2f696d672e736869656c64732e696f2f67726174697061792f6461796c65726565732e7376673f7374796c653d666c61742d737175617265)](https://gratipay.com/daylerees)

Sanitizer Package
=================

[](#sanitizer-package)

Sanitizers can be used to standardize data to ease validation, or provide data consistency.

Basic Usage
-----------

[](#basic-usage)

First construct a rules array.

```
$rules = [
    'name'      => 'trim',
    'email'     => 'trim|strtolower'
];

```

Rules can contain either callable functions, or the name of a sanitizer binding (more later). You can use either a pipe `|` or an array to specify multiple sanitization rules.

The sanitizer can be executed in the following fashion.

```
$sanitizer = new Sanitizer;
$sanitizer->sanitize($rules, $data);

```

Here's a full example.

```
// Construct rules array.
$rules = [
    'name'      => 'trim',
    'email'     => 'trim|strtolower'
];

// Data array to be sanitized.
$data = [
    'name' => ' Dayle ',
    'email' => ' me@DAYLEREES.com'
];

// Construct a new sanitizer.
$sanitizer = new Sanitizer;

// Execute the sanitizer.
$sanitizer->sanitize($rules, $data);

```

Here's the content of `$data` after execution.

```
[
    'name' => 'Dayle',
    'email' => 'me@daylerees.com'
]

```

Using the Laravel facade, the syntax can be made a little cleaner.

```
Sanitizer::sanitize($rules, $data);

```

Sanitize a single value like so.

```
$rules = 'trim|strtolower';
$data = '  Dayle';

Sanitizer::sanitizeValue($rules, $data);

```

Here is the value returned.

```
dayle

```

Custom Sanitization Rules
-------------------------

[](#custom-sanitization-rules)

Sanitizers can be added multiple ways.

### Using a Closure.

[](#using-a-closure)

```
Sanitizer::register('reverse', function ($field) {
    return strrev($field);
});

```

### Using a Callback.

[](#using-a-callback)

```
Sanitizer::register('reverse', [new ClassHere, 'method']);

```

### Using a class/method pair.

[](#using-a-classmethod-pair)

```
Sanitizer::register('reverse', 'Namespace\Class\Here@method');

```

The class will be resolved through an instance of the Illuminate IoC container, if no method is provided then `sanitize()` is assumed.

Installation
------------

[](#installation)

The Sanitizer package can be used stand-alone or with the Laravel Framework.

### Stand-alone

[](#stand-alone)

First include the sanitizer package.

```
"daylerees/sanitizer": "dev-master"

```

Now simply `use` the Sanitizer class.

```
use Rees\Sanitizer\Sanitizer;

```

### With Laravel

[](#with-laravel)

Include the Service Provider class within the `app/config/app.php` file.

```
'providers' => array(
    ...
    'Rees\Sanitizer\SanitizerServiceProvider'
)

```

Now simply add the facade alias.

```
'aliases' => array(
    ...
    'Sanitizer' => 'Rees\Sanitizer\Facade'
)

```

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance77

Regular maintenance activity

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~1047 days

Total

6

Last Release

157d ago

### Community

Maintainers

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

---

Top Contributors

[![daylerees](https://avatars.githubusercontent.com/u/207870?v=4)](https://github.com/daylerees "daylerees (17 commits)")[![jotafurtado](https://avatars.githubusercontent.com/u/748350?v=4)](https://github.com/jotafurtado "jotafurtado (5 commits)")[![thebuddha](https://avatars.githubusercontent.com/u/1663077?v=4)](https://github.com/thebuddha "thebuddha (3 commits)")[![NoMan2000](https://avatars.githubusercontent.com/u/812215?v=4)](https://github.com/NoMan2000 "NoMan2000 (2 commits)")[![Schnoop](https://avatars.githubusercontent.com/u/1263407?v=4)](https://github.com/Schnoop "Schnoop (2 commits)")[![joshhornby](https://avatars.githubusercontent.com/u/5455767?v=4)](https://github.com/joshhornby "joshhornby (2 commits)")[![TimothyLoyer](https://avatars.githubusercontent.com/u/1606132?v=4)](https://github.com/TimothyLoyer "TimothyLoyer (1 commits)")[![luisdalmolin](https://avatars.githubusercontent.com/u/403446?v=4)](https://github.com/luisdalmolin "luisdalmolin (1 commits)")[![neilcrookes](https://avatars.githubusercontent.com/u/24232?v=4)](https://github.com/neilcrookes "neilcrookes (1 commits)")[![curranjensen](https://avatars.githubusercontent.com/u/9090089?v=4)](https://github.com/curranjensen "curranjensen (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/markuper-sanitizer/health.svg)

```
[![Health](https://phpackages.com/badges/markuper-sanitizer/health.svg)](https://phpackages.com/packages/markuper-sanitizer)
```

###  Alternatives

[illuminate/validation

The Illuminate Validation package.

18936.7M1.4k](/packages/illuminate-validation)[spatie/laravel-honeypot

Preventing spam submitted through forms

1.6k6.0M60](/packages/spatie-laravel-honeypot)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[axlon/laravel-postal-code-validation

Worldwide postal code validation for Laravel and Lumen

3853.3M1](/packages/axlon-laravel-postal-code-validation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)

PHPackages © 2026

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