PHP code example of hdvinnie / laravel-html-purifier
1. Go to this page and download the library: Download hdvinnie/laravel-html-purifier library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
\clean('This is my H1 title', 'titles');
\clean('This is my H1 title', array('Attr.EnableID' => true));
Purifier::clean('This is my H1 title', 'titles');
Purifier::clean('This is my H1 title', array('Attr.EnableID' => true));
Purifier::clean('This is my H1 title', 'titles', function (HTMLPurifier_Config $config) {
$uri = $config->getDefinition('URI');
$uri->addFilter(new HTMLPurifier_URIFilter_NameOfFilter(), $config);
});
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use HDVinnie\Purifier\Casts\CleanHtml;
use HDVinnie\Purifier\Casts\CleanHtmlInput;
use HDVinnie\Purifier\Casts\CleanHtmlOutput;
class User extends Model
{
protected $casts = [
'bio' => CleanHtml::class, // cleans both when getting and setting the value
'description' => CleanHtmlInput::class, // cleans when setting the value
'history' => CleanHtmlOutput::class, // cleans when getting the value
];
}