Download the PHP package blaspsoft/blasp without Composer

On this page you can find all versions of the php package blaspsoft/blasp. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package blasp

GitHub Workflow Status (main) Total Downloads Latest Version License

Blasp - Advanced Profanity Filter for Laravel

Blasp is a powerful, extensible profanity filter for Laravel. Version 4 is a ground-up rewrite with a driver-based architecture, severity scoring, masking strategies, Eloquent model integration, and a clean fluent API.

Features

Requirements

Installation

Publish configuration:

Quick Start

Fluent API

All builder methods return a PendingCheck and can be chained:

Result Object

The Result object is returned by every check() call:

Method Returns Description
isOffensive() bool Text contains profanity
isClean() bool Text is clean
clean() string Text with profanities masked
original() string Original unmodified text
score() int Severity score (0-100)
count() int Total profanity matches
uniqueWords() array Unique base words detected
severity() ?Severity Highest severity in matches
words() Collection MatchedWord objects with position, length, severity
toArray() array Full result as array
toJson() string Full result as JSON

Result implements JsonSerializable, Stringable (returns clean text), and Countable.

Detection Types

The regex driver detects obfuscated profanity:

Type Example Detected As
Straight match fucking fucking
Substitution fÛck!ng, f4ck fucking, fuck
Separators f-u-c-k-i-n-g, f@ck fucking, fuck
Doubled ffuucckkiinngg fucking
Combination f-uuck!ng fucking

Separator limit: The regex driver allows up to 3 separator characters between each letter (e.g., f--u--c--k). This covers all realistic obfuscation patterns while keeping regex complexity low enough for PHP-FPM environments.

The pattern driver only detects straight word-boundary matches.

The phonetic driver uses metaphone() + Levenshtein distance to catch words that sound like profanity but are spelled differently:

Type Example Detected As
Phonetic spelling phuck fuck
Shortened form fuk fuck
Sound-alike sheit shit

Configure sensitivity in config/blasp.php under drivers.phonetic. A curated false-positive list prevents common words like "fork", "duck", and "beach" from being flagged.

Pipeline Driver

The pipeline driver chains multiple drivers together so a single check() call runs all of them. It uses union merge semantics — text is flagged if any driver finds a match.

When multiple drivers detect the same word at the same position, duplicates are removed — only the longest match is kept. Masks are applied from the merged result, and the score is recalculated across all matches.

Configure the default sub-drivers in config/blasp.php:

Eloquent Integration

The Blaspable trait automatically checks model attributes during save:

Per-Model Overrides

Reject Mode

In reject mode, saving a model with profanity throws ProfanityRejectedException and the model is not persisted:

Disabling Checking

Events

A ModelProfanityDetected event fires whenever profanity is detected on a model attribute (both sanitize and reject modes):

Middleware

Use CheckProfanity to filter incoming request fields. A blasp middleware alias is registered automatically:

Action Behaviour
reject (default) Returns 422 JSON with field errors
sanitize Replaces profane fields in the request and continues

Configure which fields to check in config/blasp.php:

Validation Rules

String Rule

Fluent Rule Object

Blade Directive

The @clean directive sanitizes and escapes text for safe display in views:

Output is HTML-escaped via e() for XSS safety.

Str / Stringable Macros

Blasp registers macros on Laravel's Str and Stringable classes:

Configuration

Full config/blasp.php reference:

Custom Drivers

Implement DriverInterface and register with the manager:

Caching

Blasp caches check() results by default. When the same text is checked with the same configuration (language, driver, severity, allow/block lists), the cached result is returned instantly.

Configure caching in config/blasp.php:

Result caching is automatically bypassed when using a CallbackMask (closures can't be serialized). Clear both dictionary and result caches with:

Or programmatically:

Artisan Commands

Testing

Faking

Disabling Filtering

Events

Enable global events with 'events' => true in config:

Event Fired When Properties
ProfanityDetected check() finds profanity result, originalText
ContentBlocked Middleware detects profanity result, request, field, action
ModelProfanityDetected Blaspable trait detects profanity model, attribute, result

ModelProfanityDetected always fires (not gated by the events config).

Migrating from v3

Namespace Changes

v3 v4
Blaspsoft\Blasp\Facades\Blasp Blaspsoft\Blasp\Facades\Blasp (unchanged)
Blaspsoft\Blasp\ServiceProvider Blaspsoft\Blasp\BlaspServiceProvider

The Laravel auto-discovery handles provider/alias registration automatically. The facade namespace is the same as v3, so no import changes are needed for the facade.

Config Changes

v3 Key v4 Key Notes
default_language language default_language still works as alias
mask_character mask mask_character still works as alias
cache_driver cache.driver cache_driver still works as alias
default New: driver selection (regex/pattern)
severity New: minimum severity level
events New: enable global events
allow / block New: global allow/block lists
middleware New: middleware configuration section
model New: Blaspable trait configuration

Result API Changes

v3 Method v4 Method
hasProfanity() isOffensive()
getCleanString() clean()
getSourceString() original()
getProfanitiesCount() count()
getUniqueProfanitiesFound() uniqueWords()

All v3 methods still work as deprecated aliases.

Builder API Changes

v3 Method v4 Method
maskWith($char) mask($char)
allLanguages() inAllLanguages()
language($lang) in($lang)
configure($profanities, $falsePositives) block(...$words) / allow(...$words)

All v3 methods still work as deprecated aliases.

New in v4

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Changelog

See CHANGELOG.md for detailed version history.

License

Blasp is open-sourced software licensed under the MIT license.


All versions of blasp with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^8.0|^9.0|^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package blaspsoft/blasp contains the following files

Loading the files please wait ...