Sensitive Fliter for Laravel5 / Lumen based on tuyuwei/SensitiveWord.
composer require yankewei/laravel-sensitive
Add the following line to the section providers
of config/app.php
:
'providers' => [
//...
Yankewei\LaravelSensitive\SensitiveServiceProvider::class,
],
as optional, you can use facade:
'aliases' => [
//...
'Sensitive' => Yankewei\LaravelSensitive\Facades\Sensitive::class,
],
Add the following line to bootstrap/app.php
after // $app->withEloquent();
...
// $app->withEloquent();
$app->register(Yankewei\LaravelSensitive\SensitiveServiceProvider::class);
...
Using facade:
$interference = ['&', '*'];
$filename = './words.txt'; //每个敏感词独占一行
Sensitive::interference($interference); //添加干扰因子
Sensitive::addwords($filename); //需要过滤的敏感词
$txt = "我说的日本册,滚&蛋不是。。。";
$words = Sensitive::filter($txt);
dd($words);
"我说的**册,***不是。。。"
MIT