Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Blasp Laravel Package

blaspsoft/blasp

Advanced profanity filtering for Laravel with driver-based detection (regex/pattern/phonetic/pipeline), multi-language support, severity scoring, masking strategies, Eloquent trait, middleware and validation rules, events, and test fakes. Powers blasp.app API.

View on GitHub
Deep Wiki
Context7

Blasp is a powerful and customisable profanity filter package for Laravel applications

Frequently asked questions about Blasp
How do I integrate Blasp into Laravel validation rules to block profanity in form submissions?
Use the `blasp` validation rule with customizable options like `language`, `severity`, or `score`. For example, `Validator::make($data, ['comment' => 'required|blasp:language=es,severity=high'])` blocks Spanish words with high severity. The rule integrates seamlessly with Laravel’s validation pipeline and supports middleware-style rejection.
What’s the performance impact of using the phonetic driver in a high-traffic Laravel API?
The phonetic driver adds ~10–50ms per check due to Metaphone and Levenshtein distance calculations. For high-traffic APIs, cache frequent checks or use the faster `pattern` driver for exact matches. Benchmark under your expected load—Blasp includes testing utilities to simulate real-world usage.
Can Blasp handle mixed-language inputs (e.g., Spanish and English in the same text) without false positives?
Yes, Blasp supports multi-language detection and normalizes text per language. For mixed inputs, specify all relevant languages (e.g., `Blasp::check()->in(['en', 'es'])`). The phonetic driver may still flag edge cases, so test with your specific use cases and adjust the `false_positives` list in the config.
How do I configure Blasp to reject profanity in Eloquent models but allow mild words in private messages?
Use the `Blaspable` trait on your model and set `reject_on_save = true` in the config. For context-aware rules, override the `blaspConfig()` method in your model to dynamically adjust severity thresholds. For example, private messages could use `Blasp::check()->minSeverity(30)` while public posts use `minSeverity(70)`.
What happens if the Blasp API (blasp.app) goes down, and how can I ensure offline reliability?
Blasp defaults to local word lists if the API is unreachable. Configure a fallback in `blasp.php` by setting `'api_fallback' => 'local'`. For critical systems, preload word lists into Redis or the database. The package emits `ProfanityDetected` events, so you can log failures for monitoring.
Is there a way to customize masking strategies per context (e.g., grawlix for public APIs, asterisks for internal tools)?
Yes, use the `mask()` method with context-specific callbacks. For example, `Blasp::check()->mask('grawlix')->in('en')` for public APIs or `Blasp::check()->mask('*****')->in('es')` for internal tools. You can also create custom masking strategies by extending the `MaskStrategy` class.
How do I test Blasp’s profanity detection in PHPUnit, especially for edge cases like Unicode obfuscation?
Use `Blasp::fake()` to simulate detections with predefined responses. For Unicode tests, include obfuscated terms like `fuck` in your test strings and assert severity scores. The package provides assertions like `assertProfanityDetected()` and `assertMasked()` to validate behavior.
Which Laravel versions and PHP versions does Blasp support, and are there plans for older versions?
Blasp requires **Laravel 8.0+** and **PHP 8.2+** due to modern features like enums and named arguments. There are no plans to support older versions, but the driver-based architecture makes it easier to fork for legacy systems if needed. Check the [GitHub issues](https://github.com/Blaspsoft/blasp/issues) for migration guidance.
Can I extend Blasp to add custom drivers (e.g., for industry-specific slang or machine learning models)?
Absolutely. Blasp’s driver architecture lets you create custom drivers by implementing the `DriverInterface`. For example, you could build a `MachineLearningDriver` or a `DomainSlangDriver`. Publish your driver in `app/Blasp/Driver` and register it in the `blasp.php` config under `drivers`.
What are the alternatives to Blasp for Laravel profanity filtering, and why should I choose this package?
Alternatives include `spatie/laravel-profanity-filter` (simpler but less flexible) or `league/htmlpurifier` (focused on HTML sanitization). Blasp stands out with **multi-language support**, **severity scoring**, **Eloquent/middleware integration**, and **driver extensibility**. It’s ideal for apps needing granular control, like moderation systems or compliance-heavy platforms.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai