PHPackages                             yasser-elgammal/pure-text - 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. yasser-elgammal/pure-text

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

yasser-elgammal/pure-text
=========================

Filter Bad Words

1.0.3(9mo ago)108MITPHP

Since Nov 8Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/YasserElgammal/pure-text)[ Packagist](https://packagist.org/packages/yasser-elgammal/pure-text)[ RSS](/packages/yasser-elgammal-pure-text/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)DependenciesVersions (7)Used By (0)

PureText
========

[](#puretext)

**PureText** is a Laravel package for filtering and replacing inappropriate or unwanted words within model attributes automatically. Designed to be customizable and efficient, PureText allows developers to specify filterable attributes for each model and handle multiple languages seamlessly. With a simple setup and flexible configuration, this package is ideal for applications requiring automatic content moderation.

---

Features
--------

[](#features)

- **Automatic Filtering**: Automatically filters designated model attributes upon saving.
- **Customizable Words List**: Easily modify the list of inappropriate words and replacements from the config file.
- **Language Support**: Works with multiple languages, including Arabic and other non-Latin character sets.
- **Trait Integration**: Apply the `Filterable` trait to models, specifying which attributes should be filtered.
- **Service Provider Configuration**: Provides easy configuration via a service provider and includes a singleton service for optimal performance.
- **Custom Validation Rule**: `pure_text`

Installation
------------

[](#installation)

1. Install the package via Composer:

    ```
    composer require yasser-elgammal/pure-text
    ```
2. Publish the configuration file:

    ```
    php artisan vendor:publish --provider="YasserElgammal\PureText\PureTextServiceProvider"
    ```
3. Configure your list of words to filter in the `config/badwords.php` file.

Usage
-----

[](#usage)

1. **Add the Trait to Your Model**

    Use the `PureTextFilterable` trait in any model where you need to filter specific attributes.

    ```
    use YasserElgammal\PureText\Traits\PureTextFilterable;

    class Post extends Model
    {
        use PureTextFilterable;

        protected $filterable = ['title', 'content'];
    }
    ```
2. **Configuring Filterable Attributes**

    Define `protected $filterable` on the model with an array of attribute names you want to filter.

Configuration
-------------

[](#configuration)

The configuration file `badwords.php` allows you to define:

- `words`: An array of bad words that should be filtered.
- `replacement`: The replacement text for filtered words, defaulting to `***`.

Example
-------

[](#example)

Here's a basic example of usage in a controller:

```
$post = new Post();
$post->title = "This is a badword example";
$post->content = "Some more text with badword";
$post->save();

echo $post->title; // Outputs: This is a ***
```

Other Usage :: With Custom Validation Rule: `pure_text`
-------------------------------------------------------

[](#other-usage--with-custom-validation-rule-pure_text)

This package provides a custom validation rule `pure_text`
that checks if the given text contains prohibited words using `PureTextFilterService`
and prevents the creation or update if prohibited words are found.

```
$request->validate([
    'content' => 'required|pure_text'
]);

## Contributing

Contributions are welcome! Please fork this repository and submit a pull request for any improvements.
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance58

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~68 days

Total

5

Last Release

277d ago

### Community

Maintainers

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

---

Top Contributors

[![YasserElgammal](https://avatars.githubusercontent.com/u/35766609?v=4)](https://github.com/YasserElgammal "YasserElgammal (12 commits)")

### Embed Badge

![Health badge](/badges/yasser-elgammal-pure-text/health.svg)

```
[![Health](https://phpackages.com/badges/yasser-elgammal-pure-text/health.svg)](https://phpackages.com/packages/yasser-elgammal-pure-text)
```

###  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)[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)[crazybooot/base64-validation

Laravel validators for base64 encoded files

1341.9M8](/packages/crazybooot-base64-validation)

PHPackages © 2026

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