PHPackages                             veltix/purifier - 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. [Security](/categories/security)
4. /
5. veltix/purifier

ActivePackage[Security](/categories/security)

veltix/purifier
===============

Laravel HtmlPurifier Package

v1.0.0(1mo ago)018↑400%MITPHPPHP ^7.2|^8.0

Since Mar 18Pushed 1mo agoCompare

[ Source](https://github.com/veltix/Purifier)[ Packagist](https://packagist.org/packages/veltix/purifier)[ Docs](https://github.com/mewebstudio/purifier)[ RSS](/packages/veltix-purifier/feed)WikiDiscussions master Synced 1mo ago

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

HTMLPurifier for Laravel 5/6/7/8/9/10/11/12
===========================================

[](#htmlpurifier-for-laravel-56789101112)

[![Build Status](https://camo.githubusercontent.com/89bd025da98024db8b737f0d121f7c2a690595b18a1747838de7f5c1fdf2a3e3/68747470733a2f2f7472617669732d63692e6f72672f6d6577656273747564696f2f50757269666965722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/github/mewebstudio/Purifier)[![codecov](https://camo.githubusercontent.com/807a7d05db57285f22357db96e478c133ddc2a969ce9b87112d7483b2f9a4731/68747470733a2f2f636f6465636f762e696f2f67682f6d6577656273747564696f2f50757269666965722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mewebstudio/Purifier)[![Latest Stable Version](https://camo.githubusercontent.com/cc000077c509fa8a79b105404ea4e1202060b949a37e34a555510ae34d565be1/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f50757269666965722f762f737461626c652e737667)](https://packagist.org/packages/mews/Purifier)[![Latest Unstable Version](https://camo.githubusercontent.com/5a0d0927a248bffd4f6b7efdd1bcc545d8947ebe4d85c8343f5d712a9657a25d/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f50757269666965722f762f756e737461626c652e737667)](https://packagist.org/packages/mews/Purifier)[![License](https://camo.githubusercontent.com/609a5403ad71a0e405a21cfea78523ecd2323ad8f25e3f9a2c928da27cad9873/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f50757269666965722f6c6963656e73652e737667)](https://packagist.org/packages/mews/Purifier)[![Total Downloads](https://camo.githubusercontent.com/62f29453f48b309b4efda0fed44a08ee6efbc8be11367a0e3918aa7fb6e15c95/68747470733a2f2f706f7365722e707567782e6f72672f6d6577732f50757269666965722f646f776e6c6f6164732e737667)](https://packagist.org/packages/mews/Purifier)

A simple [Laravel](http://www.laravel.com/) service provider for easily using [HTMLPurifier](http://htmlpurifier.org/) inside Laravel. From their website:

> HTML Purifier is a standards-compliant HTML filter library written in PHP. HTML Purifier will not only remove all malicious code (better known as XSS) with a thoroughly audited, secure yet permissive whitelist, it will also make sure your documents are standards compliant, something only achievable with a comprehensive knowledge of W3C's specifications. Tired of using BBCode due to the current landscape of deficient or insecure HTML filters? Have a WYSIWYG editor but never been able to use it? Looking for high-quality, standards-compliant, open-source components for that application you're building? HTML Purifier is for you!

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

[](#installation)

### For Laravel 5.5+

[](#for-laravel-55)

Require this package with composer:

```
composer require mews/purifier

```

The service provider will be auto-discovered. You do not need to add the provider anywhere.

### For Laravel 5.0 to 5.4

[](#for-laravel-50-to-54)

Require this package with composer:

```
composer require mews/purifier

```

Find the `providers` key in `config/app.php` and register the HTMLPurifier Service Provider.

```
    'providers' => [
        // ...
        Mews\Purifier\PurifierServiceProvider::class,
    ]
```

Find the `aliases` key in `config/app.php` and register the Purifier alias.

```
    'aliases' => [
        // ...
        'Purifier' => Mews\Purifier\Facades\Purifier::class,
    ]
```

### For Laravel 4

[](#for-laravel-4)

Check out [HTMLPurifier for Laravel 4](https://github.com/mewebstudio/Purifier/tree/master-l4)

Usage
-----

[](#usage)

Use these methods inside your requests or middleware, wherever you need the HTML cleaned up:

```
clean(Input::get('inputname'));
```

or

```
Purifier::clean(Input::get('inputname'));
```

dynamic config

```
clean('This is my H1 title', 'titles');
clean('This is my H1 title', array('Attr.EnableID' => true));
```

or

```
Purifier::clean('This is my H1 title', 'titles');
Purifier::clean('This is my H1 title', array('Attr.EnableID' => true));
```

use [URI filter](http://htmlpurifier.org/docs/enduser-uri-filter.html)

```
Purifier::clean('This is my H1 title', 'titles', function (HTMLPurifier_Config $config) {
    $uri = $config->getDefinition('URI');
    $uri->addFilter(new HTMLPurifier_URIFilter_NameOfFilter(), $config);
});
```

Alternatively, in Laravel 7+, if you're looking to clean your HTML inside your Eloquent models, you can use our custom casts:

```
