PHP code example of sloyakuza / laravel-html-purifier
1. Go to this page and download the library: Download sloyakuza/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/ */
sloyakuza / laravel-html-purifier example snippets
\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 SLOYakuza\Purifier\Casts\CleanHtml;
use SLOYakuza\Purifier\Casts\CleanHtmlInput;
use SLOYakuza\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
];
}