Laravel Packages

Blasp is a Profanity Filter Package for Laravel

Published
Blasp is a Profanity Filter Package for Laravel image

Blasp is a Laravel profanity filter package that helps detect and mask profane words. It provides profanity detection, substitution options, obfuscation, and more.

use Blaspsoft\Blasp\Facades\Blasp;
 
$sentence = 'Laravel News kicks ass!';
$blasp = Blasp::check($sentence);
 
$blasp->getSourceString(); // "Laravel News kicks ass!"
$blasp->getCleanString(); // "Laravel News kicks ***!"
$blasp->hasProfanity(); // true
$blasp->getProfanitiesCount(); // 1
$blasp->getUniqueProfanitiesFound(); // ['ass']

Besides straight matches, this package also matches various like substitution (i.e., a$$), obscured profanity (i.e., a-s-s), repeated letters, and combinations of all of them. Along with the Blasp facade, this package provides a validation rule you can use to validate form input for profanity:

$validated = $request->validate([
'sentence' => ['blasp_check'],
]);
 
// If the sentence contains profanities, validation will fail.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article