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

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

graham-campbell/security
========================

Security Is An Anti-XSS Wrapper For Laravel

v11.2.0(2y ago)2491.4M↓12.9%343MITPHPPHP ^8.0.2CI passing

Since Aug 15Pushed 1y ago12 watchersCompare

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

READMEChangelog (10)Dependencies (6)Versions (58)Used By (3)

Laravel Security
================

[](#laravel-security)

Laravel Security was created by, and is maintained by [Graham Campbell](https://github.com/GrahamCampbell), and is a [voku/anti-xss](https://github.com/voku/anti-xss) wrapper for [Laravel](https://laravel.com/), using [graham-campbell/security-core](https://github.com/GrahamCampbell/Security-Core). Feel free to check out the [change log](CHANGELOG.md), [releases](https://github.com/GrahamCampbell/Laravel-Security/releases), [security policy](https://github.com/GrahamCampbell/Laravel-Security/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/71477506-68a5a600-27e2-11ea-8c23-84dc5b8e3915.png)](https://user-images.githubusercontent.com/2829600/71477506-68a5a600-27e2-11ea-8c23-84dc5b8e3915.png)

[![Build Status](https://camo.githubusercontent.com/6c5b77dacdbb3c7b1cc0c4378b759050ba12ff00368f1cf14532ae1cf3d65c7b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f47726168616d43616d7062656c6c2f4c61726176656c2d53656375726974792f74657374732e796d6c3f6c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/GrahamCampbell/Laravel-Security/actions?query=workflow%3ATests)[![StyleCI Status](https://camo.githubusercontent.com/2e3b0f7fb553fd1ae6c99e6fb63299ed0b3b5bd046fb965a3a52faee4b852002/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f31323039303735352f736869656c64)](https://github.styleci.io/repos/12090755)[![Software License](https://camo.githubusercontent.com/c090e080484e2a2bc766446291d04437db823929042bf614b26a1643660ddf6f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e3f7374796c653d666c61742d737175617265)](LICENSE)[![Packagist Downloads](https://camo.githubusercontent.com/1a6981769e6416ca0bd53d18a33118b8fdeac72784acf1a51c440806b0851192/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67726168616d2d63616d7062656c6c2f73656375726974793f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graham-campbell/security)[![Latest Version](https://camo.githubusercontent.com/07c7280fe027a828421852c2be715f1668cc4a9073dd808a82eb5e3af7b41cc8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f47726168616d43616d7062656c6c2f4c61726176656c2d53656375726974793f7374796c653d666c61742d737175617265)](https://github.com/GrahamCampbell/Laravel-Security/releases)

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

[](#installation)

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

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

```
$ composer require "graham-campbell/security:^11.2"
```

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

You can also optionally alias our facade:

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

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

[](#configuration)

Laravel Security supports optional configuration.

To get started, you'll need to publish all vendor assets:

```
$ php artisan vendor:publish
```

This will create a `config/security.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

There are two config options:

##### Evil configuration

[](#evil-configuration)

This option (`'evil'`) defines the evil attributes and tags, which will always be stripped from the input.

##### Replacement string

[](#replacement-string)

This option (`'replacement'`) defines the replacement string, which will be used to take the place of removed portions of strings where XSS was present.

Usage
-----

[](#usage)

##### Security

[](#security)

This is the class of most interest. It is bound to the ioc container as `'security'` and can be accessed using the `Facades\Security` facade. There is one public method of interest.

The `'clean'` method will parse a string removing XSS vulnerabilities, on a best effort basis.

##### Facades\\Security

[](#facadessecurity)

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

##### SecurityServiceProvider

[](#securityserviceprovider)

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.

##### Further Information

[](#further-information)

You may see an example of implementation in [Laravel Binput](https://github.com/GrahamCampbell/Laravel-Binput).

Security
--------

[](#security-1)

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-Security/security/policy).

License
-------

[](#license)

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

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

[](#for-enterprise)

Available as part of the Tidelift Subscription

The maintainers of `graham-campbell/security` 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-security?utm_source=packagist-graham-campbell-security&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity57

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

Recently: every ~182 days

Total

58

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

9.1.x-dev → v10.0.02022-05-30

10.0.x-dev → v11.0.02023-02-26

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

v10.0.0PHP ^7.4.15 || ^8.0.2

v11.0.0PHP ^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 (440 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (1 commits)")

---

Tags

hacktoberfestframeworklaravelsecurityGraham CampbellGrahamCampbellxssLaravel Securityanti-xss

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
