PHPackages                             graham-campbell/binput - 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. graham-campbell/binput

Abandoned → [voku/anti-xss](/?search=voku%2Fanti-xss)ArchivedLibrary[Framework](/categories/framework)

graham-campbell/binput
======================

Binput Is An Input Protector For Laravel

v11.1.0(2y ago)179500.0k↓11.2%188MITPHPPHP ^8.0.2CI passing

Since Aug 15Pushed 1y ago8 watchersCompare

[ Source](https://github.com/GrahamCampbell/Laravel-Binput)[ Packagist](https://packagist.org/packages/graham-campbell/binput)[ GitHub Sponsors](https://github.com/GrahamCampbell)[ Fund](https://tidelift.com/funding/github/packagist/graham-campbell/binput)[ RSS](/packages/graham-campbell-binput/feed)WikiDiscussions 11.1 Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (56)Used By (8)

Laravel Binput
==============

[](#laravel-binput)

Laravel Binput was created by, and is maintained by [Graham Campbell](https://github.com/GrahamCampbell), and is an input protector for [Laravel](https://laravel.com/) that prevents potentially dangerous elements like `` tags in any input you receive, from doing harm. It utilises my [Laravel Security](https://github.com/GrahamCampbell/Laravel-Security) package, which cleans the input using [voku/anti-xss](https://github.com/voku/anti-xss). Feel free to check out the [change log](CHANGELOG.md), [releases](https://github.com/GrahamCampbell/Laravel-Binput/releases), [security policy](https://github.com/GrahamCampbell/Laravel-Binput/security/policy), [license](LICENSE), [code of conduct](.github/CODE_OF_CONDUCT.md), and [contribution guidelines](.github/CONTRIBUTING.md).

[![Banner](https://user-images.githubusercontent.com/2829600/71477342-6000a000-27e1-11ea-93d0-1ee413a31ab1.png)](https://user-images.githubusercontent.com/2829600/71477342-6000a000-27e1-11ea-93d0-1ee413a31ab1.png)

[![Build Status](https://camo.githubusercontent.com/33c5d2a00323540385d4724ea1e27bbfb0e1cdf7d6e42ca0022d34103c7d35f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f47726168616d43616d7062656c6c2f4c61726176656c2d42696e7075742f74657374732e796d6c3f6c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/GrahamCampbell/Laravel-Binput/actions?query=workflow%3ATests)[![StyleCI Status](https://camo.githubusercontent.com/9502db7cd05e2364fe33408812da1c85ef5faae381112afc7ab4f9bf93cb66e5/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f31323039303330382f736869656c64)](https://github.styleci.io/repos/12090308)[![Software License](https://camo.githubusercontent.com/c090e080484e2a2bc766446291d04437db823929042bf614b26a1643660ddf6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e3f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Downloads](https://camo.githubusercontent.com/a013de243c45dbb71a052dbdb10dfb052e18ab5f1d0d936194c1e28483f3f793/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67726168616d2d63616d7062656c6c2f62696e7075743f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graham-campbell/binput)[![Latest Version](https://camo.githubusercontent.com/79e2a37c40decb41716b3c536add768a617c2002056774abf9971e8f8faba8f0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f47726168616d43616d7062656c6c2f4c61726176656c2d42696e7075743f7374796c653d666c61742d737175617265)](https://github.com/GrahamCampbell/Laravel-Binput/releases)

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

[](#installation)

This version requires [PHP](https://www.php.net/) 8.0-8.3 and supports [Laravel](https://laravel.com/) 9-11.

BinputL5.5L5.6L5.7L5.8L6L7L8L9L10L115.1✅✅✅❌❌❌❌❌❌❌6.2✅✅✅✅✅❌❌❌❌❌7.1✅✅✅✅✅✅❌❌❌❌8.0❌❌❌❌✅✅❌❌❌❌9.1❌❌❌❌✅✅✅✅❌❌10.0❌❌❌❌❌❌✅✅❌❌11.1❌❌❌❌❌❌❌✅✅✅To get the latest version, simply require the project using [Composer](https://getcomposer.org/):

```
$ composer require "graham-campbell/binput:^11.1"
```

Once installed, if you are not using automatic package discovery, then you need to register the `GrahamCampbell\Security\SecurityServiceProvider` and `GrahamCampbell\Binput\BinputServiceProvider` service providers in your `config/app.php`.

You can also optionally alias our facade:

```
        'Binput' => GrahamCampbell\Binput\Facades\Binput::class,
```

Configuration
-------------

[](#configuration)

Laravel Binput requires no configuration. Just follow the simple install instructions and go!

Usage
-----

[](#usage)

##### Binput

[](#binput)

This is the class of most interest. It is bound to the ioc container as `'binput'` and can be accessed using the `Facades\Binput` facade. There are a few public methods of interest.

The `'all'`, `'get'`, `'input'`, `'only'`, `'except'`, and `'old'` methods have an identical api to the methods found on the laravel request class accept from they all accept two extra parameters at the end. The first extra parameter is a boolean representing if the input should be trimmed. The second extra parameter is a boolean representing if the input should be xss cleaned. Both extra parameters are default to true.

There are two additional methods added to the public api. The first is a method called `'map'` which will remap the output from the `'only'` method. The `'map'` function requires an associative array as the first parameter. The second method is the `'clean'` function. It takes three parameters. The first is the value to be cleaned (it can be an array, and will be recursively iterated over and cleaned), and the final two are trim and clean, which behave in the same way as earlier.

Any methods not found on this binput class will actually fall back to the laravel request class with a dynamic call function, so every other method on the request class is available in exactly the same way it would be on the Laravel request class.

##### Facades\\Binput

[](#facadesbinput)

This facade will dynamically pass static method calls to the `'binput'` object in the ioc container which by default is the `Binput` class.

##### BinputServiceProvider

[](#binputserviceprovider)

This class contains no public methods of interest. This class should be added to the providers array in `config/app.php`. This class will setup ioc bindings.

##### Real Examples

[](#real-examples)

Here you can see an example of just how simple this package is to use.

```
// request input data: ['test' => '123', 'foo' => 'alert(\'bar\');    ']

$input = Binput::all(); // ['test' => '123', 'foo' => '']
```

Security
--------

[](#security)

If you discover a security vulnerability within this package, please send an email to . All security vulnerabilities will be promptly addressed. You may view our full security policy [here](https://github.com/GrahamCampbell/Laravel-Binput/security/policy).

License
-------

[](#license)

Laravel Binput is licensed under [The MIT License (MIT)](LICENSE).

For Enterprise
--------------

[](#for-enterprise)

Available as part of the Tidelift Subscription

The maintainers of `graham-campbell/binput` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-graham-campbell-binput?utm_source=packagist-graham-campbell-binput&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity52

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 99.5% 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 ~76 days

Recently: every ~251 days

Total

56

Last Release

442d ago

Major Versions

v7.1.1 → v8.0.12020-04-14

7.1.x-dev → 8.0.x-dev2020-08-08

8.0.x-dev → v9.0.02020-08-14

v9.1.0 → 10.0.x-dev2022-05-30

v10.0.0 → 11.0.x-dev2023-12-04

PHP version history (9 changes)v0.1.0-alphaPHP &gt;=5.3.3

v1.0.0-beta1PHP &gt;=5.4.7

v3.1.0PHP &gt;=5.5.9

v4.0.0PHP ^7.0

v5.0.0PHP ^7.1.3

v8.0.0PHP ^7.2.5

v9.0.0PHP ^7.2.5 || ^8.0

10.0.x-devPHP ^7.4.15 || ^8.0.2

11.0.x-devPHP ^8.0.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d95eb26cb8f3919bb5ca3b6d823daeabbf259663778a970349b245c580713c8e?d=identicon)[graham-campbell](/maintainers/graham-campbell)

---

Top Contributors

[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (397 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (2 commits)")

---

Tags

hacktoberfestframeworklaravelsecurityGraham CampbellGrahamCampbellxssinputbetter inputbetterBinputLaravel Binput

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graham-campbell-binput/health.svg)

```
[![Health](https://phpackages.com/badges/graham-campbell-binput/health.svg)](https://phpackages.com/packages/graham-campbell-binput)
```

###  Alternatives

[graham-campbell/markdown

Markdown Is A CommonMark Wrapper For Laravel

1.3k7.1M64](/packages/graham-campbell-markdown)[graham-campbell/manager

Manager Provides Some Manager Functionality For Laravel

39221.1M134](/packages/graham-campbell-manager)[graham-campbell/throttle

Throttle Is A Rate Limiter For Laravel

7102.3M11](/packages/graham-campbell-throttle)[graham-campbell/github

GitHub Is A GitHub Bridge For Laravel

6411.7M19](/packages/graham-campbell-github)[graham-campbell/exceptions

Provides A Powerful Error Response System For Both Development And Production

5911.3M4](/packages/graham-campbell-exceptions)[graham-campbell/digitalocean

DigitalOcean Is A DigitalOcean Bridge For Laravel

509343.1k2](/packages/graham-campbell-digitalocean)

PHPackages © 2026

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