PHPackages                             heyitsmi/content-guard - 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. [Search &amp; Filtering](/categories/search)
4. /
5. heyitsmi/content-guard

ActiveLibrary[Search &amp; Filtering](/categories/search)

heyitsmi/content-guard
======================

A content sanitization library to filter negative content and online gambling spam.

v1.2.0(4mo ago)321MITPHPPHP ^8.0

Since Nov 29Pushed 4mo agoCompare

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

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

ContentGuard
============

[](#contentguard)

**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
--------

[](#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
------------

[](#installation)

You can install the package via composer:

```
composer require heyitsmi/content-guard
```

Configuration (Laravel)
-----------------------

[](#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
-----

[](#usage)

### 1. Using Laravel Facade (Recommended for Laravel)

[](#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

[](#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)

[](#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)

[](#publication-laravel)

Publish the assets (CSS and JS):

```
php artisan vendor:publish --tag="content-guard-assets"
```

#### Assets Inclusion

[](#assets-inclusion)

In your layout file (e.g., `app.blade.php`), inclusion the assets using the blade directive:

```

    ...
    @contentGuardAssets

```

#### Usage

[](#usage-1)

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: `slot`

Users can click on the blurred/masked word to reveal the original content.

How It Works
------------

[](#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
-------

[](#testing)

To run the unit tests included in this package:

```
composer test
```

Contributing
------------

[](#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
-------

[](#license)

The MIT License (MIT). Please see License File for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance76

Regular maintenance activity

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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.

###  Release Activity

Cadence

Every ~21 days

Total

3

Last Release

129d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca339e1ee60405c3cacc7efb9b87097efdd755f346c92506442297c70a0746ed?d=identicon)[heyitsmi](/maintainers/heyitsmi)

---

Tags

librarypackagephpphplaravelfilterindonesiacontent moderationspam-detectionjudi-online

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/heyitsmi-content-guard/health.svg)

```
[![Health](https://phpackages.com/badges/heyitsmi-content-guard/health.svg)](https://phpackages.com/packages/heyitsmi-content-guard)
```

###  Alternatives

[pos-lifestyle/laravel-nova-date-range-filter

A Laravel Nova date range filter.

16179.1k](/packages/pos-lifestyle-laravel-nova-date-range-filter)[ambengers/query-filter

Laravel package for filtering resources with request query string

3513.5k](/packages/ambengers-query-filter)

PHPackages © 2026

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