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

ActivePackage[Security](/categories/security)

moomnng/purifier
================

Laravel 5 HtmlPurifier Package

2.0.9(8y ago)011MITPHPPHP &gt;=5.5.9

Since Jan 25Pushed 8y ago1 watchersCompare

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

READMEChangelogDependencies (8)Versions (14)Used By (0)

HTMLPurifier for Laravel 5
==========================

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

[![Build Status](https://camo.githubusercontent.com/569b46953a0074fb4224a88d4742357c434b4dbe5659a09fdc5bb5046ee815c9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6577656273747564696f2f50757269666965722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mewebstudio/Purifier/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/9a6668c8fbc6011b605eb0c890e9e09df0435799339cb9ee95b4ff0e106a3da5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d6577656273747564696f2f50757269666965722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mewebstudio/Purifier/?branch=master)

A simple [Laravel 5](http://www.laravel.com/) service provider for including the [HTMLPurifier for Laravel 5](https://github.com/mewebstudio/purifier).

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

This package can be installed via [Composer](http://getcomposer.org) by requiring the `mews/purifier` package in your project's `composer.json`:

```
{
    "require": {
        "laravel/framework": "~5.0",
        "mews/purifier": "~2.0",
    }
}
```

or

Require this package with composer:

```
composer require mews/purifier

```

Update your packages with `composer update` or install with `composer install`.

Usage
-----

[](#usage)

To use the HTMLPurifier Service Provider, you must register the provider when bootstrapping your Laravel application. There are essentially two ways to do this.

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

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

Find the `aliases` key in `app/config/app.php`.

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

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

[](#configuration)

To use your own settings, publish config.

`$ php artisan vendor:publish --provider="Mews\Purifier\PurifierServiceProvider"`

Config file `config/purifier.php` should like this

```
return [
    'encoding'      => 'UTF-8',
    'finalize'      => true,
    'cachePath'     => storage_path('app/purifier'),
    'cacheFileMode' => 0755,
    'settings'      => [
        'default' => [
            'HTML.Doctype'             => 'HTML 4.01 Transitional',
            'HTML.Allowed'             => 'div,b,strong,i,em,u,a[href|title],ul,ol,li,p[style],br,span[style],img[width|height|alt|src]',
            'CSS.AllowedProperties'    => 'font,font-size,font-weight,font-style,font-family,text-decoration,padding-left,color,background-color,text-align',
            'AutoFormat.AutoParagraph' => true,
            'AutoFormat.RemoveEmpty'   => true,
        ],
        'test'    => [
            'Attr.EnableID' => 'true',
        ],
        "youtube" => [
            "HTML.SafeIframe"      => 'true',
            "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
        ],
        'custom_definition' => [
            'id'  => 'html5-definitions',
            'rev' => 1,
            'debug' => false,
            'elements' => [
                // http://developers.whatwg.org/sections.html
                ['section', 'Block', 'Flow', 'Common'],
                ['nav',     'Block', 'Flow', 'Common'],
                ['article', 'Block', 'Flow', 'Common'],
                ['aside',   'Block', 'Flow', 'Common'],
                ['header',  'Block', 'Flow', 'Common'],
                ['footer',  'Block', 'Flow', 'Common'],

				// Content model actually excludes several tags, not modelled here
                ['address', 'Block', 'Flow', 'Common'],
                ['hgroup', 'Block', 'Required: h1 | h2 | h3 | h4 | h5 | h6', 'Common'],

				// http://developers.whatwg.org/grouping-content.html
                ['figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'],
                ['figcaption', 'Inline', 'Flow', 'Common'],

				// http://developers.whatwg.org/the-video-element.html#the-video-element
                ['video', 'Block', 'Optional: (source, Flow) | (Flow, source) | Flow', 'Common', [
                    'src' => 'URI',
					'type' => 'Text',
					'width' => 'Length',
					'height' => 'Length',
					'poster' => 'URI',
					'preload' => 'Enum#auto,metadata,none',
					'controls' => 'Bool',
                ]],
                ['source', 'Block', 'Flow', 'Common', [
					'src' => 'URI',
					'type' => 'Text',
                ]],

				// http://developers.whatwg.org/text-level-semantics.html
                ['s',    'Inline', 'Inline', 'Common'],
                ['var',  'Inline', 'Inline', 'Common'],
                ['sub',  'Inline', 'Inline', 'Common'],
                ['sup',  'Inline', 'Inline', 'Common'],
                ['mark', 'Inline', 'Inline', 'Common'],
                ['wbr',  'Inline', 'Empty', 'Core'],

				// http://developers.whatwg.org/edits.html
                ['ins', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
                ['del', 'Block', 'Flow', 'Common', ['cite' => 'URI', 'datetime' => 'CDATA']],
            ],
            'attributes' => [
                ['iframe', 'allowfullscreen', 'Bool'],
                ['table', 'height', 'Text'],
                ['td', 'border', 'Text'],
                ['th', 'border', 'Text'],
                ['tr', 'width', 'Text'],
                ['tr', 'height', 'Text'],
                ['tr', 'border', 'Text'],
            ],
        ],
        'custom_attributes' => [
            ['a', 'target', 'Enum#_blank,_self,_target,_top'],
        ],
        'custom_elements' => [
            ['u', 'Inline', 'Inline', 'Common'],
        ],
    ],

];
```

Example
-------

[](#example)

default

```
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));
```

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 74.3% 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 ~120 days

Recently: every ~126 days

Total

12

Last Release

3166d ago

Major Versions

1.0.2 → 2.0.02015-04-11

PHP version history (3 changes)1.0.1PHP &gt;=5.3.0

2.0.0PHP &gt;=5.4

2.0.6PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/59adacec106a2ad3704154e9c89d964bc26d9140e9d18dd81f39210f008c9b09?d=identicon)[moomnng](/maintainers/moomnng)

---

Top Contributors

[![mewebstudio](https://avatars.githubusercontent.com/u/2125733?v=4)](https://github.com/mewebstudio "mewebstudio (75 commits)")[![LukeTowers](https://avatars.githubusercontent.com/u/7253840?v=4)](https://github.com/LukeTowers "LukeTowers (6 commits)")[![itbdw](https://avatars.githubusercontent.com/u/1267057?v=4)](https://github.com/itbdw "itbdw (5 commits)")[![micheleangioni](https://avatars.githubusercontent.com/u/7933034?v=4)](https://github.com/micheleangioni "micheleangioni (3 commits)")[![moomnng](https://avatars.githubusercontent.com/u/10327776?v=4)](https://github.com/moomnng "moomnng (2 commits)")[![JellyBool](https://avatars.githubusercontent.com/u/6011686?v=4)](https://github.com/JellyBool "JellyBool (2 commits)")[![Texungo](https://avatars.githubusercontent.com/u/3602520?v=4)](https://github.com/Texungo "Texungo (1 commits)")[![AJenbo](https://avatars.githubusercontent.com/u/204594?v=4)](https://github.com/AJenbo "AJenbo (1 commits)")[![Xiphin](https://avatars.githubusercontent.com/u/3348428?v=4)](https://github.com/Xiphin "Xiphin (1 commits)")[![AlfredoRamos](https://avatars.githubusercontent.com/u/4165935?v=4)](https://github.com/AlfredoRamos "AlfredoRamos (1 commits)")[![chaosmail](https://avatars.githubusercontent.com/u/2969388?v=4)](https://github.com/chaosmail "chaosmail (1 commits)")[![lsousa](https://avatars.githubusercontent.com/u/861294?v=4)](https://github.com/lsousa "lsousa (1 commits)")[![moura137](https://avatars.githubusercontent.com/u/1171111?v=4)](https://github.com/moura137 "moura137 (1 commits)")[![Omranic](https://avatars.githubusercontent.com/u/406705?v=4)](https://github.com/Omranic "Omranic (1 commits)")

---

Tags

securityPurifierhtmlpurifierxsslaravel5 Securitylaravel5 HtmlPurifierlaravel5 Purifier

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/moomnng-purifier/health.svg)

```
[![Health](https://phpackages.com/badges/moomnng-purifier/health.svg)](https://phpackages.com/packages/moomnng-purifier)
```

###  Alternatives

[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[luketowers/purifier

Laravel 5 HtmlPurifier Package

3280.0k9](/packages/luketowers-purifier)[tzsk/otp

A secure, database-free One-Time Password (OTP) generator and verifier for PHP and Laravel.

241641.4k1](/packages/tzsk-otp)[xemlock/htmlpurifier-html5

HTML5 support for HTML Purifier

1052.9M11](/packages/xemlock-htmlpurifier-html5)[ercsctt/laravel-file-encryption

Secure file encryption and decryption for Laravel applications

642.6k](/packages/ercsctt-laravel-file-encryption)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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