PHPackages                             chromabits/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. chromabits/purifier

AbandonedLibrary[Validation &amp; Sanitization](/categories/validation)

chromabits/purifier
===================

HTMLPurifier package for Laravel 5

2.1.1(11y ago)1324.8k4LGPLPHPPHP &gt;=5.4.0

Since Jan 25Pushed 10y ago3 watchersCompare

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

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

[Purifier](https://github.com/etcinit/purifier) [![Build Status](https://camo.githubusercontent.com/15ba80a69eeabebdf42eb112b64384b2c0b55320215a6e35a9a7631515387360/68747470733a2f2f7472617669732d63692e6f72672f657463696e69742f70757269666965722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/etcinit/purifier)
===============================================================================================================================================================================================================================================================================================================================

[](#purifier-)

A HTMLPurifier service for Laravel 5

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

[](#installation)

> Note: This package is for Laravel 5 only. It does not include a Facade and it requires certain "Contracts" interfaces only available in Laravel 5.

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

```
{
    "require": {
        "laravel/framework": "~5.0",
        "chromabits/purifier": "~2.1"
    }
}
```

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

Usage
-----

[](#usage)

To use the HTMLPurifier service, you must register the service provider when bootstrapping your Laravel application.

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

```
    'providers' => [
        // ...
        'Chromabits\Purifier\PurifierServiceProvider',
    ]
```

After registering the provider, classes requiring the `Chromabits\Purifier\Contracts\Purifier` contract will get the purifier service instance through dependency injection (See below for examples).

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

[](#configuration)

To use your own settings, copy the `config/purifier.php` file in this package into your application's `config` directory, and modify as needed.

You can define mutiple sets of configurations by sspecifying new entries in the `settings` array key:

```
return [
    "settings" => [
        "default" => [
            "HTML.SafeIframe" => 'true',
            "URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
        ],
        "titles" => [
            'AutoFormat.AutoParagraph' => false,
            'AutoFormat.Linkify' => false,
        ]
    ],
];
```

The service will use the `default` key as the default set of configuration, any other configuration will extend this. If a configuraiton file is not provided, the service will use safe defaults.

Example
-------

[](#example)

Full usage example with default settings within a Laravel 5 controller:

```
