PHPackages                             yosefib/laravel-libyan-badwords - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. yosefib/laravel-libyan-badwords

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

yosefib/laravel-libyan-badwords
===============================

Laravel package to filter and block bad words in Libyan dialect.

v1.0.0(9mo ago)07MITPHP

Since Sep 16Pushed 7mo agoCompare

[ Source](https://github.com/yosefibrahemali/laravel-libyan-badwords)[ Packagist](https://packagist.org/packages/yosefib/laravel-libyan-badwords)[ RSS](/packages/yosefib-laravel-libyan-badwords/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

---

🌐 Laravel Libyan Bad Words Filter
=================================

[](#-laravel-libyan-bad-words-filter)

A lightweight **Laravel package** to filter and clean **Libyan offensive words** from text. Supports normalization, diacritics removal, repeated letters, and common spelling variations.

---

⚙️ Installation
---------------

[](#️-installation)

Install via Composer:

```
composer require yosefib/laravel-libyan-badwords:^1.0
```

Publish the configuration file (optional, but highly recommended):

```
php artisan vendor:publish --provider="Yosef\LibyanBadwords\LibyanBadWordsServiceProvider" --tag=config
```

This will create `config/libyan_badwords.php`, where you can add your custom list of bad words.

---

🚀 How to Use
------------

[](#-how-to-use)

### 1. Simple Text Filtering

[](#1-simple-text-filtering)

Use the service container to resolve the `LibyanBadWordsFilter` instance.

```
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Yosef\LibyanBadwords\LibyanBadWordsFilter;

class MyController extends Controller
{
    public function store(Request $request)
    {
        $text = $request->input('comment');

        // Resolve the filter from the service container
        $filter = app(LibyanBadWordsFilter::class);

        // Check if the text contains any bad words
        if ($filter->contains($text)) {
            // If it does, clean the text and get the filtered output
            $cleanText = $filter->clean($text);

            // Output: هاذا واحد **** يكتب
            return response()->json(['message' => 'Your text has been filtered.', 'clean_text' => $cleanText]);
        }

        // If the text is clean, proceed
        return response()->json(['message' => 'Your text is clean.']);
    }
}
```

### 2. Customizing the Replacement

[](#2-customizing-the-replacement)

You can pass a custom string to the `clean` method to use instead of the default `****`.

```
$text = "زآمـلل ومبَعّر";

// Use a custom replacement string
$filter = app(LibyanBadwordsFilter::class);
$censoredText = $filter->clean($text, '[censored]');

// Output: [censored] [censored]
```

### 3. Middleware Example

[](#3-middleware-example)

You can use the package within a middleware to automatically clean all incoming request data.

```
