heyitsmi/content-guard
Composer 安装命令:
composer require heyitsmi/content-guard
包简介
A content sanitization library to filter negative content and online gambling spam.
README 文档
README
ContentGuard is a robust PHP content sanitization library specifically designed for the Indonesian web ecosystem. It helps developers filter out online gambling spam (judi online), profanity, and hate speech with advanced detection capabilities.
Unlike simple string replacement tools, ContentGuard uses an intelligent Regex Engine to detect "Leet Speak" (visual masking) commonly used by spammers (e.g., detecting s10t g4c0r as slot gacor).
Features
- ✅ Smart Detection: Catch masked words like
g4c0r,s.l.o.t,judi, etc. - ✅ Pre-built Dictionary: Comes with a comprehensive database of Indonesian gambling terms and profanity.
- ✅ Laravel Ready: Includes Service Provider and Facade for seamless integration.
- ✅ Customizable: Add your own blocklist and configure strictness.
- ✅ Zero Dependencies: Lightweight and fast.
Installation
You can install the package via composer:
composer require heyitsmi/content-guard
Configuration (Laravel)
If you are using Laravel, you can publish the configuration file to customize the behavior (e.g., changing the mask character or adding custom keywords).
Run the following command:
php artisan vendor:publish --tag="content-guard-config"
This will create a config/content-guard.php file in your application.
Usage
1. Using Laravel Facade (Recommended for Laravel)
You can use the ContentGuard facade anywhere in your controllers, jobs, or blade directives.
use Heyitsmi\ContentGuard\Facades\ContentGuard; // 1. Check if text contains bad words (returns boolean) $isSpam = ContentGuard::hasBadWords("Ayo main s10t g4c0r hari ini!"); if ($isSpam) { return back()->withErrors(['message' => 'Your comment contains restricted content.']); } // 2. Sanitize text (returns clean string) $cleanText = ContentGuard::sanitize("Jangan main judi online!"); // Output: "Jangan main **** ******!"
2. Standalone PHP Usage
If you are not using Laravel, you can instantiate the class directly.
use Heyitsmi\ContentGuard\ContentGuard; $guard = new ContentGuard(); $input = "Situs g.a.c.o.r terpercaya"; if ($guard->hasBadWords($input)) { echo "Spam detected!"; } echo $guard->sanitize($input);
3. Client-side Masking (Blur or Hidden)
ContentGuard can wrap detected words in HTML tags, allowing you to use CSS and JavaScript for a premium "click-to-reveal" experience.
Publication (Laravel)
Publish the assets (CSS and JS):
php artisan vendor:publish --tag="content-guard-assets"
Assets Inclusion
In your layout file (e.g., app.blade.php), inclusion the assets using the blade directive:
<head> ... @contentGuardAssets </head>
Usage
Use the wrap() method instead of sanitize() to get HTML-tagged content:
$text = "Bocoran slot gacor hari ini"; // Default is 'blur' echo ContentGuard::wrap($text); // Or use 'mask' for a solid black box echo ContentGuard::wrap($text, 'mask');
The wrap() method will generate:
<span class="cg-word cg-blur" data-cg-word="slot">slot</span>
Users can click on the blurred/masked word to reveal the original content.
How It Works
ContentGuard converts standard keywords into flexible Regex patterns based on a Substitution Map.
-
Input:
slot -
Regex Generated:
/\b(s|5|\$|z)[\W_]*(l|1|!|\|)[\W_]*(o|0|@|ø)[\W_]*(t|7|\+)\b/i -
Matches:
slot,s1ot,s.l.o.t,s-l-o-t,sl0t, etc.
Testing
To run the unit tests included in this package:
composer test
Contributing
Contributions are welcome! If you find new slang words or spam patterns popular in Indonesia, please submit a Pull Request to update the src/Dictionary files.
License
The MIT License (MIT). Please see License File for more information.
heyitsmi/content-guard 适用场景与选型建议
heyitsmi/content-guard 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「filter」 「laravel」 「indonesia」 「content-moderation」 「spam-detection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 heyitsmi/content-guard 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 heyitsmi/content-guard 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 heyitsmi/content-guard 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Nova searchable filter for belongsTo relationships.
Symfony DataGridBundle
Data provider for yii2
This Laravel Nova package allows you to detach filters from the filter dropdown
Laravel filter elequent
Laravel filter elequent
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-08