yankewei / laravel-sensitive
过滤敏感词汇的laravel包,使用DFA算法
Installs: 10 322
Dependents: 0
Suggesters: 0
Security: 0
Stars: 61
Watchers: 3
Forks: 9
Open Issues: 1
Requires
- php: >=5.6
This package is not auto-updated.
Last update: 2020-08-22 05:53:28 UTC
README
Sensitive Fliter for Laravel5 / Lumen based on tuyuwei/SensitiveWord.
Install
composer require yankewei/laravel-sensitive
For Laravel
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, ],
For Lumen
Add the following line to bootstrap/app.php
after // $app->withEloquent();
... // $app->withEloquent(); $app->register(Yankewei\LaravelSensitive\SensitiveServiceProvider::class); ...
Usage
Using facade:
$interference = ['&', '*']; $filename = './words.txt'; //每个敏感词独占一行 Sensitive::interference($interference); //添加干扰因子 Sensitive::addwords($filename); //需要过滤的敏感词 $txt = "我说的日本册,滚&蛋不是。。。"; $words = Sensitive::filter($txt); dd($words); "我说的**册,***不是。。。"
License
MIT