PHPackages                             joshuabedford/laravel-word-filter - 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. joshuabedford/laravel-word-filter

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

joshuabedford/laravel-word-filter
=================================

A word and/or profanity filter for Laravel.

v1.0.4(7y ago)270MITPHPPHP &gt;=5.5.9

Since Mar 6Pushed 7y ago1 watchersCompare

[ Source](https://github.com/JoshuaBedford/laravel-word-filter)[ Packagist](https://packagist.org/packages/joshuabedford/laravel-word-filter)[ Docs](https://github.com/JoshuaBedford/laravel-word-filter)[ RSS](/packages/joshuabedford-laravel-word-filter/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (5)Dependencies (5)Versions (6)Used By (0)

Note: NOT FULLY TESTED
======================

[](#note-not-fully-tested)

P.S. Yes, I am cringing my way through this one. No, I don't know what most of these words/phrases mean.

Laravel Word Filter
===================

[](#laravel-word-filter)

A package that, once installed, allows prohibited words to be filtered out or refused. Works as standalone or with Laravel Validator. Utilizes two database tables to hold a whitelist and blacklist of acceptable and prohibited words. Can be used with Laravel's Form [Validation](https://laravel.com/docs/5.6/validation) functionality (E.G. prevent certain usernames) to refuse certain inputs and require user correction.

Installation
============

[](#installation)

```
composer require joshuabedford/laravel-word-filter

```

Configure
---------

[](#configure)

```
php artisan vendor:publish

```

The command above will publish the appropriate files. Next, we have to install the database tables.

```
php artisan migrate

```

Now that the database tables are installed, we can seed them with data.

```
php artisan db:seed --class=JoshuaBedford\\LaravelWordFilter\\Database\\Seeds\\DatabaseSeeder

```

This should seed the database with our list of words that we consider necessary to blacklist or whitelist.

Usage
=====

[](#usage)

```
$string = app('wordFilter')->filter('something with a bad word');
```

The `$string` will contain the filtered result.

You can also define things inline

```
$string = app('wordFilter')->replaceWith('#')->replaceFullWords(false)->filter('something with a bad word'));
```

You can also use the `word` filter with Laravels [Validation](https://laravel.com/docs/5.6/validation) feature:

```
$request->validate([
    'username' => 'required|word|unique:users|max:255',
]);
```

Options
=======

[](#options)

- `filter($string = string, $details = boolean)` pass a string to be filtered.

    - Enable details to have an array of results returned: ```
        [
          "orig" => "",
          "clean" => "",
          "hasMatch" => boolean,
          "matched" => []
        ]
        ```
- `reset()` reset `replaceWith` and `replaceFullWords` to defaults.
- `replaceWith(string)` change the chars used to replace filtered strings.
- `replaceFullWords(boolean)` enable to replace full words, disable to replace partial.

Credits
=======

[](#credits)

This package is based on [LaravelProfanityFilter](https://github.com/Askedio/laravel-profanity-filter) which is based on [banbuilder](https://github.com/snipe/banbuilder).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~0 days

Total

5

Last Release

2623d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/882f71a9a1621fb42df8e922a47b0ae5280b83a9ba7f28b24d7ce981c82ca41a?d=identicon)[JoshuaBedford](/maintainers/JoshuaBedford)

---

Top Contributors

[![JoshuaBedford](https://avatars.githubusercontent.com/u/13459258?v=4)](https://github.com/JoshuaBedford "JoshuaBedford (19 commits)")

---

Tags

laravelvalidationwordfilterprofanityvalidate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joshuabedford-laravel-word-filter/health.svg)

```
[![Health](https://phpackages.com/badges/joshuabedford-laravel-word-filter/health.svg)](https://phpackages.com/packages/joshuabedford-laravel-word-filter)
```

###  Alternatives

[aura/filter

Filters to validate and sanitize objects and arrays.

173561.0k10](/packages/aura-filter)[pos-lifestyle/laravel-nova-date-range-filter

A Laravel Nova date range filter.

16179.1k](/packages/pos-lifestyle-laravel-nova-date-range-filter)[tapp/filament-value-range-filter

Filament country code field.

2362.2k](/packages/tapp-filament-value-range-filter)[webbingbrasil/filament-datefilter

Date filter component for filament tables.

1479.4k](/packages/webbingbrasil-filament-datefilter)[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)
