2017 © Pedro Peláez
 

library purify

An HTML Purifier for Laravel 5

image

eugenecooper/purify

An HTML Purifier for Laravel 5

  • Wednesday, July 5, 2017
  • by eugenecooper
  • Repository
  • 1 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Purify

Travis CI Scrutinizer Code Quality Latest Stable Version Total Downloads License, (*1)

Description

Purify is an HTML Purifier helper for Laravel 5. It utilizes the fantastic package HTMLPurifier by ezyang. All credit for purification goes to him., (*2)

Installation

To install Purify, insert the following require in your composer.json file:, (*3)

"stevebauman/purify": "1.1.*"

Now run a composer update on your project source., (*4)

Once that's finished, insert the service provider in your app/config/app.php (or config/app.php for Laravel 5) configuration file:, (*5)

'Stevebauman\Purify\PurifyServiceProvider'

You can also use the facade if you wish:, (*6)

'Purify' => 'Stevebauman\Purify\Facades\Purify'

Usage

Cleaning a String

To clean a users input, simply use the clean method:, (*7)

$input = '

Test, (*8)

'; $cleaned = Purify::clean($input); echo $cleaned; // Returns '

Test, (*9)

'
Cleaning an Array

Need to purify an array of user input? Just pass in an array:, (*10)

$inputArray = [
    '

Test, (*11)

', '

Test, (*12)

', ]; $cleaned = Purfiy::clean($inputArray); var_dump($cleaned); // Returns [0] => '

Test, (*13)

' [1] => '

Test, (*14)

'
Dynamic Configuration

Need to add or modify rules for a single input? Pass in a configuration array into the second parameter:, (*15)

$configuration = ['HTML.Allowed' => 'div,b,a[href]'];

$cleaned = Purify::clean($input, $configuration);

Note: Configuration passed into the second parameter is merged with the current configuration and will overwrite array keys you supply. This allows you to add settings on the fly. Simply pass false into the third parameter if you do not want the configuration merged., (*16)

$configuration = ['HTML.Allowed' => 'div,b,a[href]'];

$cleaned = Purify::clean($input, $configuration, $merge = false);
Replacing the HTML Purifier instance

Need to replace the HTML Purifier instance with your own? Call the setPurifier() method:, (*17)

$purifier = new HTMLPurifier();

Purify::setPurifier($purifier);
Replacing the HTML Purifier Configuration instance

Need to replace the HTML Purifier Configuration instance with your own? Call the setPurifierConfig() method:, (*18)

$settings = ['HTML.Allowed' => 'div,b,a[href]'];

$configuration = new HTMLPurifier_Config($settings);

Purify::setPurifierConfig($configuration);

Configuration

Inside the configuration file, the entire settings array is passed directly to the HTML Purifier configuration, so feel free to customize it however you wish. For the configuration documentation, please visit the HTML Purifier Website:, (*19)

http://htmlpurifier.org/live/configdoc/plain.html, (*20)

The Versions

05/07 2017

dev-master

9999999-dev

An HTML Purifier for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steve Bauman

laravel html clean cleaner purifier purify purification

05/07 2017

1.1.2

1.1.2.0

An HTML Purifier for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steve Bauman

laravel html clean cleaner purifier purify purification

02/11 2015

v1.1.1

1.1.1.0

An HTML Purifier for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steve Bauman

laravel html clean cleaner purifier purify purification

17/09 2015

v1.1.0

1.1.0.0

An HTML Purifier for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steve Bauman

laravel html clean cleaner purifier purify purification

08/05 2015

v1.0.1

1.0.1.0

An HTML Purifier for Laravel 4 / 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steve Bauman

laravel html clean cleaner purifier purify purification

07/05 2015

v1.0.0

1.0.0.0

An HTML Purifier for Laravel 4 / 5

  Sources   Download

MIT

The Requires

 

The Development Requires

by Steve Bauman

laravel html clean cleaner purifier purify purification