PHPackages                             fixer112/laravel-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. fixer112/laravel-sanitizer

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

fixer112/laravel-sanitizer
==========================

Laravel middleware to sanitize inputs and block malicious bots and codes

v0.0.8(1y ago)077↓84.2%MITPHPPHP &gt;=8.0

Since Jun 19Pushed 1y agoCompare

[ Source](https://github.com/fixer112/laravel-sanitizer)[ Packagist](https://packagist.org/packages/fixer112/laravel-sanitizer)[ RSS](/packages/fixer112-laravel-sanitizer/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

Laravel Input Sanitizer Middleware
==================================

[](#laravel-input-sanitizer-middleware)

[![Laravel](https://camo.githubusercontent.com/4f56b721d6129d21b974aad5bd0d89b049835f9f5905867bd7d21f8f32506d02/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e782d6f72616e6765)](https://camo.githubusercontent.com/4f56b721d6129d21b974aad5bd0d89b049835f9f5905867bd7d21f8f32506d02/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31302e7825323025374325323031312e7825323025374325323031322e782d6f72616e6765)[![License](https://camo.githubusercontent.com/5711e7cff3c1fd62184281a8e7a9533b6204e97bd0278335ee3f86070c4b8c79/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f66697865723131322f6c61726176656c2d73616e6974697a6572)](https://camo.githubusercontent.com/5711e7cff3c1fd62184281a8e7a9533b6204e97bd0278335ee3f86070c4b8c79/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f66697865723131322f6c61726176656c2d73616e6974697a6572)[![Packagist](https://camo.githubusercontent.com/048640c4b749642a28a6ff4b6968537682858fcbf740b76165f233c1c526e92f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66697865723131322f6c61726176656c2d73616e6974697a6572)](https://camo.githubusercontent.com/048640c4b749642a28a6ff4b6968537682858fcbf740b76165f233c1c526e92f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66697865723131322f6c61726176656c2d73616e6974697a6572)

A Laravel middleware package that sanitizes all incoming request data by stripping out potentially malicious scripts, SQL keywords, and dangerous shell command inputs. It also blocks known bots and crawlers based on the `User-Agent`.

---

✨ Features
----------

[](#-features)

- Filters out common XSS/JS/HTML injections
- Removes SQL injection keywords
- Removes shell command patterns like `cmd`, `powershell`, `shutdown`
- Sanitizes all fields except `password` and `confirm_password`
- Blocks basic bot `User-Agent` patterns
- Lightweight and auto-runs on every request (if configured)

---

🚀 Installation
--------------

[](#-installation)

```
composer require fixer112/sanitizer
```

⚙️ Configuration
----------------

[](#️-configuration)

To publish the configuration file:

```
php artisan vendor:publish --tag=config --provider="Fixer112\Sanitizer\SanitizerServiceProvider"
```

This will create config/sanitizer.php with:

```
return [
    'global' => true, // Automatically apply to all web and API routes
];
```

If global is true, the sanitizer middleware will be added to both the web and api middleware stacks automatically.

🛡️ What It Sanitizes
--------------------

[](#️-what-it-sanitizes)

It removes the following:

- `, , , , etc.`
- onerror=, onclick=, javascript: URIs
- data:text/html;base64, patterns
- Dangerous SQL terms: select, update, drop, exec, etc.
- Shell/OS commands like cmd, powershell, shutdown, etc.
- Character patterns like &amp;, |, ;, &lt;, &gt; that can trigger shell execution

🧪 Usage
-------

[](#-usage)

No additional setup required if global =&gt; true in config.

If not, register the middleware manually in your Kernel.php:

```
protected $middleware = [
    \Fixer112\Sanitizer\Middleware\Sanitizer::class,
];
```

Or add it only to certain routes:

```
Route::middleware(['sanitizer'])->group(function () {
    // routes
});
```

🧼 Skipped Fields
----------------

[](#-skipped-fields)

By default, these fields are not sanitized:

password

confirm\_password

You can customize this inside the package or fork it to your needs.

🤖 Bot Protection Rejects requests with suspicious or missing User-Agent headers like:

- bot
- crawler
- spider
- curl
- httpclient
- scrapy

###  Health Score

27

—

LowBetter than 46% of packages

Maintenance49

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community6

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.

###  Release Activity

Cadence

Every ~6 days

Total

8

Last Release

378d ago

PHP version history (2 changes)v0.0.1PHP ^8.0

v0.0.6PHP &gt;=8.0

### Community

Maintainers

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

---

Top Contributors

[![fixer112](https://avatars.githubusercontent.com/u/25584514?v=4)](https://github.com/fixer112 "fixer112 (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

137236.2k8](/packages/statamic-rad-pack-runway)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3622.8k](/packages/duncanmcclean-statamic-cargo)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21327.3k4](/packages/ecotone-laravel)

PHPackages © 2026

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