PHP基于确定有穷自动机(DFA)敏感词过滤器,支持 Laravel 框架。
$ composer require snstvwd/filter
'providers' => [
.
.
.
Snstvwd\Filter\Providers\FilterSerivceProvider::class
],
'aliases' => [
.
.
.
'Filter' => Snstvwd\Filter\Facades\Filter::class
]
php artisan vendor:publish --provider="Snstvwd\Filter\Providers\FilterSerivceProvider"
use Filter;
public function test () {
$text = '他是傻逼吗?';
$filter = Filter::filter($text)->getText();
dump($filter);
}
他是???吗?