PHPackages                             cledilsonweb/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. cledilsonweb/badwords

ActiveLibary

cledilsonweb/badwords
=====================

Badwords PHP is a small lightweight PHP library for detecting 'bad' words, e.g. profanity, in content.

v0.0.1(3y ago)017MITPHPPHP &gt;=5.3

Since Sep 16Pushed 2y agoCompare

[ Source](https://github.com/cledilsonweb/badwords)[ Packagist](https://packagist.org/packages/cledilsonweb/badwords)[ RSS](/packages/cledilsonweb-badwords/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Badwords PHP
============

[](#badwords-php)

Badwords PHP is **small lightweight PHP library** for detecting "bad" words, e.g. profanity, in content. This is a fork from mioga-technik/badwords to customize.

Aside from the obvious matching if a word is present in a string, the filter also tries to detect words similar to those in the list, e.g. `gl@d` and `glad`.

The library is designed to be **highly configurable**, from the word lists used to the character replacement configuration at the heart of the filter.

**Note:** At present the default configuration provided is **not** a bulletproof/catch-all solution, but it will catch most variations. This will become more robust over time.

Requirements
------------

[](#requirements)

- The library is only supported on PHP 5.6 and up.
- Composer is required.

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

[](#installation)

To install include it in your projects's `composer.json`.

```
    $ composer require cledilsonweb/badwords
    $ composer update
```

There are no additional dependencies required for this package to work.

Usage
-----

[](#usage)

### File Method:

[](#file-method)

The simplest way to use the library is as follows,

```
    $dictionary = new \Badword\Dictionary\Php('path/to/dictionary_list.php');
    $config = new \Badword\Filter\Config\Standard();
    $filter = new \Badword\Filter($dictionary, $config);

    $result = $filter->filter('My content...');
    $result->getRiskLevel();
    $result->getMatches();
    $result->getMatchesAndRiskLevels();
    $result->getHighlightedContent();
```

Explained,

- First load your list of "bad" words using the `Dictionary` objects, or create your own and implement the `Dictionary` interface.
- Define a configuration for the filter to use (a default `Standard` configuration is provided).
- Create the `Filter` passing your dictionary(s) and config.
- Filter your content using the `filter()` method.
- Use the `Result` object to analyse your content.

### Array Method:

[](#array-method)

```
    // An example moderate dictionary.
    $dictionaryWords = array(
        'some',
        'bad',
        'words'
    );

    $dictionary = new \Badword\Dictionary\PhpArray($dictionaryWords, 1);
    $config = new \Badword\Filter\Config\Standard();
    $filter = new \Badword\Filter($dictionary, $config);

    $result = $filter->filter('My content...');
    $result->getRiskLevel();
    $result->getMatches();
    $result->getMatchesAndRiskLevels();
    $result->getHighlightedContent();
```

### Object Layer Method \[new\]:

[](#object-layer-method-new)

```
   $dictionaryWords = array(
        'reject' => array(
            'maecenas',
            'mauris',
            'luctus'
        ),
        'moderate' => array(
            'consectetur',
            'neque',
            'velit'
        )
   );

   $Badwords = new \Badword\Badwords($dictionaryWords);

   $result = $Badwords->Filter()->filter('My content...'));
   $result->getRiskLevel();
   $result->getMatches();
   $result->getMatchesAndRiskLevels();
   $result->getHighlightedContent();
```

Testing
-------

[](#testing)

To run the unit tests on this package, simply run `vendor/bin/phpunit` from the package directory.

Credits
-------

[](#credits)

- This repository is maintained by [Cledilson Nascimento](https://github.com/cledilsonweb)

### Previous authors:

[](#previous-authors)

- Update Repository and push it to packagist by [Brian Schäffner](https://github.com/mioga-brian).
- Written and developed by [Stephen Melrose](http://twitter.com/stephenmelrose).
- Original concept by [Paul Lemon](http://twitter.com/anthonylime).

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

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

Unknown

Total

1

Last Release

1338d ago

### Community

Maintainers

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

---

Top Contributors

[![cledilsonweb](https://avatars.githubusercontent.com/u/44277678?v=4)](https://github.com/cledilsonweb "cledilsonweb (5 commits)")[![mioga-technik](https://avatars.githubusercontent.com/u/33415195?v=4)](https://github.com/mioga-technik "mioga-technik (3 commits)")

---

Tags

badwords

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cledilsonweb-badwords/health.svg)

```
[![Health](https://phpackages.com/badges/cledilsonweb-badwords/health.svg)](https://phpackages.com/packages/cledilsonweb-badwords)
```

PHPackages © 2026

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