PHPackages                             guanhui07/webman-sensitive - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. guanhui07/webman-sensitive

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

guanhui07/webman-sensitive
==========================

Webman 敏感词检测，过滤，标记

00PHP

Since Sep 21Pushed 1y agoCompare

[ Source](https://github.com/guanhui07/webman-sensitive)[ Packagist](https://packagist.org/packages/guanhui07/webman-sensitive)[ RSS](/packages/guanhui07-webman-sensitive/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

webman-sensitive
================

[](#webman-sensitive)

Webman 敏感词检测，过滤，标记

 [![Minimum PHP Version](https://camo.githubusercontent.com/e8223ac675b6f9feddec95a806a57528e8009d21035aca7c0650e6006fa81c36/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d3e3d382e302d3838393242462e737667)](https://packagist.org/packages/isszz/webman-sensitive) [![Minimum Webman Version](https://camo.githubusercontent.com/3dd959b671ace122302a590ff733b99831d175515f253623a3fffec4f9121dcc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7765626d616e2d3e3d312e342e782d3838393242462e737667)](https://packagist.org/packages/isszz/webman-sensitive) [![Stable Version](https://camo.githubusercontent.com/fc54e35bb803feeb03c653b94cf1bc562d2507d23230b0b236cd015eb2e6880c/68747470733a2f2f706f7365722e707567782e6f72672f6973737a7a2f7765626d616e2d73656e7369746976652f762f737461626c65)](https://packagist.org/packages/isszz/webman-sensitive) [![Total Downloads](https://camo.githubusercontent.com/12059554bd3abc0ac063c1da64c1e6d9a6b735b0b1cd7c997e99fb05e890e142/68747470733a2f2f706f7365722e707567782e6f72672f6973737a7a2f7765626d616e2d73656e7369746976652f646f776e6c6f616473)](https://packagist.org/packages/isszz/webman-sensitive) [![License](https://camo.githubusercontent.com/94e579e6a4b202e3715147459a5bac677efa904a8a8379f62e1527e476dd1dc0/68747470733a2f2f706f7365722e707567782e6f72672f6973737a7a2f7765626d616e2d73656e7369746976652f6c6963656e7365)](https://packagist.org/packages/isszz/webman-sensitive)

安装
--

[](#安装)

```
composer require isszz/webman-sensitive
```

配置
--

[](#配置)

```
return [
    'enable'  => true,

    // 支持file，array，也可以指向自己敏感词库文件路径
    // file模式时，敏感词库位于webman根目录的config/plugin/isszz/webman-sensitive/SensitiveWord.txt，也可以指向自定义的词库文件路径
    'mode' => 'file',

    'config' => [
        'repeat' => true, // 重复替换为敏感词相同长度的字符
        'replace_char' => '*', // 替换字符
        // 标记敏感词，标签生成敏感词
        'mark' => 'mark',
    ],

    // 干扰因子
    'interference_factors' => [
        ' ', '&', '*', '/', '|', '@', '.', '^', '~', '$',
    ],

    // 数组模式敏感词
    'sensitive_words' => [
        '工口',
        '里番',
        '性感美女',
    ]
];
```

使用
--

[](#使用)

facade方式

```
use isszz\sensitive\facade\Sensitive;

class Index
{
    public function add()
    {
        // 设置干扰因子
        Sensitive::interferenceFactor(['(', ')', ',', '，', ';', '；', '。']);

        // 添加一个额外的敏感词，words参数支持单敏感词，多词也可以用|分割，或者直接传入多个敏感词数组
        // words = 性感美女|分隔符
        // words = ['性感美女', '数组']
        Sensitive::add(words: '性感美女');

        // 删除的敏感词，words参数同添加的格式一样
        // 第二个参数once为true时，只针对当次: is，replace，mark，操作生效
        Sensitive::remove(words: '性感美女', once: true);

        // 检测
        if (Sensitive::is(content: '检测语句')) {
            return json(['code' => 1, 'msg' => '输入内容包含敏感词，请注意用词。']);
        }

        // 替换
        $replaced = Sensitive::add(words: '垃圾')->replace(content: '替换语句垃圾要被替换', replaceChar: '*', repeat: false);

        // 标记敏感词
        $marked = Sensitive::add(words: '尼玛')->mark(content: '标记的内容，这里尼玛要被标记', tag: 'bad');

        // 提取内容中的所有敏感词
        $badWords = Sensitive::add('狗逼')->get('提取内容中的所有敏感词，狗逼，还有SB都会被提取');

        // 自定义敏感词库
        // 文件方式
        Sensitive::custom('/config/SensitiveWord.txt')
            ->is('检测尼玛的语句');

        // 数组方式
        Sensitive::custom([
            '垃圾', '尼玛',
            //...
        ])->is('检测尼玛的语句');

        // 文件词库模式，可以添加新敏感词到词库文件
        // data参数可以是一个数组也可以是用|分割敏感词的字符串
        // append参数为true是追加模式，false时先提取词库，再去重，然后合并写入
        $sensitive->addWordToFile(data: '狗逼|傻缺', append: false);
    }
}
```

依赖注入方式

```
use isszz\sensitive\Sensitive;

class Index
{
    public function add(Sensitive $sensitive)
    {
        // 设置干扰因子
        $sensitive->interferenceFactor(['(', ')', ',', '，', ';', '；', '。']);
        // ...
    }
}
```

助手函数方式

```
class Index
{
    public function add(Sensitive $sensitive)
    {
        // 设置干扰因子，后返回的Sensitive实例可使用：is，replace，mark
        sensitive_interference_factor(['(', ')', ',', '，', ';', '；', '。'])
            ->is('检测语句尼玛');

        // 添加敏感词，后返回的Sensitive实例可使用：is，replace，mark
        sensitive_add(words: '性感美女')
            ->mark('你是一个性感美女，你说是不是？');

        // 移除敏感词，后返回的Sensitive实例可使用：is，replace，mark
        // 第二个参数once为true时，只针对当次: is，replace，mark，操作生效
        sensitive_remove(words: '工口', once: true)
            ->mark('你这个SB是不是想看工口类的动漫？哈哈！');

        // 检测敏感词
        if (sensitive_is('检测语句尼玛')) {
            return json(['code' => 1, 'msg' => '输入内容包含敏感词，请注意用词。']);
        }

        // replaceChar是用来设置要被替换的敏感词
        // repeat为true时根据检测出的敏感词长度设置replaceChar
        $replaced = sensitive_replace(content: '替换语句垃圾要被替换', replaceChar: '*', repeat: true);
        // tag参数是用来设置包裹敏感词的标签名例如: 这里SB要被标记
        $marked = sensitive_mark(content: '标记的内容，这里SB要被标记', tag: 'bad');

        // 提取内容中的所有敏感词
        $badWords = sensitive_get('谁是SB，谁是狗逼，谁是傻缺');

        // 自定义敏感词库
        // 文件方式
        sensitive_custom('/config/SensitiveWord.txt')
            ->is('检测尼玛的语句');

        // 数组方式
        sensitive_custom([
            '垃圾', '尼玛',
            //...
        ])->is('检测尼玛的语句');

        // 文件词库模式，可以添加新敏感词到词库文件
        // data参数可以是一个数组也可以是用|分割敏感词的字符串
        // append参数为true是追加模式，false时先提取词库，再去重，然后合并写入
        sensitive_add_word_to_file(data: '狗逼|傻缺', append: false);

    }
}
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3abde3fccf025ce86670101d7cfa0641d2415c9daad93e5f0c9573a2b23ddbda?d=identicon)[guanhui07](/maintainers/guanhui07)

---

Top Contributors

[![isszz](https://avatars.githubusercontent.com/u/2878463?v=4)](https://github.com/isszz "isszz (12 commits)")[![fatrbaby](https://avatars.githubusercontent.com/u/4350262?v=4)](https://github.com/fatrbaby "fatrbaby (1 commits)")[![guanhui07](https://avatars.githubusercontent.com/u/5820457?v=4)](https://github.com/guanhui07 "guanhui07 (1 commits)")

### Embed Badge

![Health badge](/badges/guanhui07-webman-sensitive/health.svg)

```
[![Health](https://phpackages.com/badges/guanhui07-webman-sensitive/health.svg)](https://phpackages.com/packages/guanhui07-webman-sensitive)
```

###  Alternatives

[webmozart/assert

Assertions to validate method input/output with nice error messages.

7.6k894.0M1.2k](/packages/webmozart-assert)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k15.9M104](/packages/bensampo-laravel-enum)[nette/forms

📝 Nette Forms: generating, validating and processing secure forms in PHP. Handy API, fully customizable, server &amp; client side validation and mature design.

54013.2M448](/packages/nette-forms)[swaggest/json-schema

High definition PHP structures with JSON-schema based validation

48612.5M73](/packages/swaggest-json-schema)[stevebauman/purify

An HTML Purifier / Sanitizer for Laravel

5325.6M19](/packages/stevebauman-purify)[ashallendesign/laravel-config-validator

A package for validating your Laravel app's config.

217905.3k5](/packages/ashallendesign-laravel-config-validator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
