PHPackages                             dax-87/badwords-it - 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. dax-87/badwords-it

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

dax-87/badwords-it
==================

Italian profanity and spam filter for PHP. Three-level detection: regex, substring, compound phrases.

00PHP

Since Apr 26Pushed 1mo agoCompare

[ Source](https://github.com/Dax-87/badwords-it)[ Packagist](https://packagist.org/packages/dax-87/badwords-it)[ RSS](/packages/dax-87-badwords-it/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

badwords-it
===========

[](#badwords-it)

Italian profanity and spam filter for PHP.

Three-level detection engine:

1. **Regex** with word boundaries — isolated words
2. **Substring** — catches concatenations like `cazzomerda`
3. **Phrases** — compound expressions like `figlio di puttana`

Email filtering checks the local part and domain name independently (no word boundaries, since emails have no spaces).

---

Live demo
---------

[](#live-demo)

🔗 **[Try it on Replit](https://replit.com/@Dax-87/badwords-it)** — type anything and see the filter in action.

> The demo uses the `replit-demo/` folder from this repo. Source is open — feel free to inspect it.

---

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

[](#requirements)

- PHP 8.0+
- Composer

---

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

[](#installation)

```
composer require dax-87/badwords-it
```

---

Usage
-----

[](#usage)

```
use BadwordsIt\Filter;

$filter = new Filter();
```

### Check a text field

[](#check-a-text-field)

```
$filter->hasProfanity('che cazzo');       // true
$filter->hasProfanity('Ciao, come stai'); // false
```

### Check an email address

[](#check-an-email-address)

```
$filter->hasProfanityEmail('merda@test.com');        // true
$filter->hasProfanityEmail('mario.rossi@gmail.com'); // false
```

### Check for spam keywords

[](#check-for-spam-keywords)

```
$filter->hasSpam('buy bitcoin now');              // true
$filter->hasSpam('Buongiorno, vorrei un preventivo'); // false
```

### Check multiple fields at once

[](#check-multiple-fields-at-once)

```
$filter->checkFields(['Mario', 'Rossi', 'Messaggio pulito']); // false
$filter->checkFields(['Mario', 'cazzo', 'testo ok']);          // true
```

### Full inspection (profanity + spam in one call)

[](#full-inspection-profanity--spam-in-one-call)

```
$result = $filter->inspect(
    textFields: [$name, $surname, $message, $address],
    email: $email
);

if ($result['profanity']) {
    // reject: profanity detected
}
if ($result['spam']) {
    // reject: spam detected
}
```

### Typical contact form integration

[](#typical-contact-form-integration)

```
require 'vendor/autoload.php';

use BadwordsIt\Filter;

$filter = new Filter();

$name    = $_POST['name']    ?? '';
$surname = $_POST['surname'] ?? '';
$email   = $_POST['email']   ?? '';
$message = $_POST['message'] ?? '';

$result = $filter->inspect([$name, $surname, $message], $email);

if ($result['profanity'] || $result['spam']) {
    http_response_code(400);
    echo json_encode(['error' => 'Content not allowed.']);
    exit;
}

// proceed with form processing
```

---

Custom word lists
-----------------

[](#custom-word-lists)

You can pass your own data files to override the defaults:

```
$filter = new Filter(
    profanityFile: '/path/to/my-profanity.php',
    spamFile:      '/path/to/my-spam.php'
);
```

Each file must return an array matching the structure of the default files in `data/`.

---

Running tests
-------------

[](#running-tests)

```
composer install
./vendor/bin/phpunit tests/
```

---

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance60

Regular maintenance activity

Popularity0

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/adb39d447ad2b5a7138eab103952a0da4306c8987c7e8e3ced05af44184ae493?d=identicon)[Dax-87](/maintainers/Dax-87)

### Embed Badge

![Health badge](/badges/dax-87-badwords-it/health.svg)

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

###  Alternatives

[ziming/laravel-zxcvbn

Zxcvbn Password validation rule for Laravel

3064.3k](/packages/ziming-laravel-zxcvbn)

PHPackages © 2026

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