PHPackages                             askedio/laravel5-profanity-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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. askedio/laravel5-profanity-filter

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

askedio/laravel5-profanity-filter
=================================

A Vendor Package Example

1.10(7y ago)52354.1k↓13.4%16[4 issues](https://github.com/Askedio/laravel-profanity-filter/issues)AGPL-3.0PHPPHP &gt;=5.5.9CI failing

Since Nov 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Askedio/laravel-profanity-filter)[ Packagist](https://packagist.org/packages/askedio/laravel5-profanity-filter)[ RSS](/packages/askedio-laravel5-profanity-filter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (10)Used By (0)

[![Build Status](https://camo.githubusercontent.com/ce585ad1a11a5ceddb9c697977938a4d0eab951c0b6ce38835d85c04ef8a2d90/68747470733a2f2f7472617669732d63692e6f72672f41736b6564696f2f6c61726176656c2d70726f66616e6974792d66696c7465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Askedio/laravel-profanity-filter)[![StyleCI](https://camo.githubusercontent.com/95477febee8ce88c45c3db0b196c931d1b07991f57f073e0fe6dcbf7f47a4001/68747470733a2f2f7374796c6563692e696f2f7265706f732f37343533313631352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/74531615)

Laravel Profanity Filter
========================

[](#laravel-profanity-filter)

Filter profanity, or other bad words, out of a string using Laravels [localization](https://laravel.com/docs/5.6/localization) feature or with any PHP application and some custom coding.

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

[](#installation)

```
composer require askedio/laravel5-profanity-filter

```

Register in config/app.php.
---------------------------

[](#register-in-configappphp)

Register the service providers in Laravel 5.4 or lower to enable the package:

```
Askedio\Laravel5ProfanityFilter\Providers\ProfanityFilterServiceProvider::class,

```

Configure
---------

[](#configure)

```
php artisan vendor:publish

```

You can edit the default list of words to filter along with the settings in `config/profanity.php`.

`replaceWith` can also be a string of chars to be randomly chosen to replace with, like `'&%^@#'`.

You can create your own list of words, per language, in `resources/lang/[language]/profanity.php`.

Usage
=====

[](#usage)

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

The `$string` will contain the filtered result.

You can also define things inline

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

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

```
$request->validate([
    'title' => 'required|profanity|unique:posts|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.

Profanity Filter with PHP
=========================

[](#profanity-filter-with-php)

You can also use this package without Laravel.

```
use Askedio\Laravel5ProfanityFilter\ProfanityFilter;

$config = []; // Data from `resources/config/profanity.php`
$badWordsArray = []; // Data from `resources/lang/[lang]/profanity.php`

$profanityFilter =  new ProfanityFilter($config, $badWordsArray);
$string = $profanityFilter->filter('something with a bad word');
```

Credits
=======

[](#credits)

This package is based on [banbuilder](https://github.com/snipe/banbuilder).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 89.7% 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 ~116 days

Recently: every ~173 days

Total

7

Last Release

2768d ago

Major Versions

1.0.9 → 5.6.x-dev2018-04-27

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1173636?v=4)[William](/maintainers/gcphost)[@gcphost](https://github.com/gcphost)

---

Top Contributors

[![gcphost](https://avatars.githubusercontent.com/u/1173636?v=4)](https://github.com/gcphost "gcphost (35 commits)")[![wrighter989](https://avatars.githubusercontent.com/u/22423056?v=4)](https://github.com/wrighter989 "wrighter989 (2 commits)")[![prashantidealittechno](https://avatars.githubusercontent.com/u/8256764?v=4)](https://github.com/prashantidealittechno "prashantidealittechno (1 commits)")[![willystadnick](https://avatars.githubusercontent.com/u/1824706?v=4)](https://github.com/willystadnick "willystadnick (1 commits)")

---

Tags

laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/askedio-laravel5-profanity-filter/health.svg)

```
[![Health](https://phpackages.com/badges/askedio-laravel5-profanity-filter/health.svg)](https://phpackages.com/packages/askedio-laravel5-profanity-filter)
```

###  Alternatives

[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)[laravel-validation-rules/us-state

Validate US States and Canada Provinces

16172.7k](/packages/laravel-validation-rules-us-state)[pacerit/laravel-polish-validation-rules

Simple Polish Validation rules for Laravel and Lumen framework

1449.9k](/packages/pacerit-laravel-polish-validation-rules)[laravel-validation-rules/ip

Validate if an ip address is public or private.

1629.7k](/packages/laravel-validation-rules-ip)[janvince/smallcontactform

Simple but flexible multi language contact form builder with custom fields, validation and passive antispam

307.4k](/packages/janvince-smallcontactform)[basillangevin/laravel-data-json-schemas

Transforms Spatie Data objects into JSON Schemas with built-in validation

1312.2k1](/packages/basillangevin-laravel-data-json-schemas)

PHPackages © 2026

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