PHPackages                             friendsofhyperf/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. friendsofhyperf/purifier

ActiveLibrary[Security](/categories/security)

friendsofhyperf/purifier
========================

Hyperf HtmlPurifier Package

v3.1.75(5mo ago)08MITPHP

Since Dec 5Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/friendsofhyperf/purifier)[ Packagist](https://packagist.org/packages/friendsofhyperf/purifier)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-purifier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (10)Used By (0)

Purifier
========

[](#purifier)

[![Latest Stable Version](https://camo.githubusercontent.com/7d7dc5b82406e985367bfca895266f4e2322377f0fcc32c286e0d6bf3e21f256/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f667269656e64736f666879706572662f7075726966696572)](https://packagist.org/packages/friendsofhyperf/purifier)[![Total Downloads](https://camo.githubusercontent.com/f4cd14ece53a850cb611539c423290ca343156d4bd4783d2666bd286b4158335/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f667269656e64736f666879706572662f7075726966696572)](https://packagist.org/packages/friendsofhyperf/purifier)[![License](https://camo.githubusercontent.com/9309fd1087d69e1bb69871943f8321d9bbfbd843ed777182da8529c89da85f91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f667269656e64736f666879706572662f7075726966696572)](https://github.com/friendsofhyperf/purifier)

HTML filter. forked from [mews/purifier](https://github.com/mewebstudio/Purifier).

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

[](#installation)

Require this package with composer:

```
composer require friendsofhyperf/purifier
```

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

Usage
-----

[](#usage)

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

```
clean($request->get('inputname'));
```

or

```
ApplicationContext::getContainer()->get(Purifier::class)->clean($request->get('inputname'));
```

dynamic config

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

or

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

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

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

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

```
