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.
Download blaspsoft/blasp
More information about blaspsoft/blasp
Files in blaspsoft/blasp
Package blasp
Short Description Blasp is a powerful and customisable profanity filter package for Laravel applications
License MIT
Homepage https://github.com/blaspsoft/blasp
Informations about the package blasp
Blasp - Advanced Profanity Filter for Laravel
Blasp is a powerful, extensible profanity filter package for Laravel that helps detect and mask profane words in text. Version 3.0 introduces a simplified API with method chaining, comprehensive multi-language support (English, Spanish, German, French), all-languages detection mode, and advanced caching for enterprise-grade performance.
β¨ Key Features
- π Method Chaining: Elegant fluent API with
Blasp::spanish()->check()
- π Multi-Language Support: English, Spanish, German, and French with language-specific normalizers
- π All Languages Mode: Check against all languages simultaneously with
Blasp::allLanguages()
- π¨ Custom Masking: Configure custom mask characters with
maskWith()
method - β‘ High Performance: Advanced caching with O(1) lookups and optimized algorithms
- π― Smart Detection: Handles substitutions, separators, variations, and false positives
- ποΈ Modern Architecture: Built on SOLID principles with dependency injection
- β Battle Tested: 148 tests with 858 assertions ensuring reliability
Installation
You can install the package via Composer:
Quick Start
Basic Usage
Simplified API with Method Chaining
Working with Results
Profanity Detection Types
Blasp can detect different types of profanities based on variations such as:
- Straight match: Direct matches of profane words.
- Substitution: Substituted characters (e.g.,
pro0fΓ‘n1ty
). - Obscured: Profanities with separators (e.g.,
p-r-o-f-a-n-i-t-y
). - Doubled: Repeated letters (e.g.,
pprrooffaanniittyy
). - Combination: Combinations of the above (e.g.,
pp-rof@n|tty
).
Laravel Validation Rule
Blasp also provides a custom Laravel validation rule called blasp_check
, which you can use to validate form input for profanity.
Example
Configuration
Blasp uses configuration files to manage profanities, separators, and substitutions. The main configuration includes:
You can publish the configuration files:
This will publish:
config/blasp.php
- Main configuration with default language settingsconfig/languages/
- Language-specific profanity lists (English, Spanish, German, French)
Custom Configuration
You can specify custom profanity and false positive lists using the configure()
method:
This is particularly useful when you need different profanity rules for specific contexts, such as username validation.
π Advanced Features (v3.0+)
All Languages Detection
Perfect for international platforms, forums, or any application with multilingual content:
Multi-Language Support
Blasp includes comprehensive support for multiple languages with automatic character normalization:
- English: Full profanity database with common variations
- Spanish: Handles accent normalization (Γ‘βa, Γ±βn)
- German: Processes umlauts (Γ€βae, ΓΆβoe, ΓΌβue) and Γβss
- French: Accent and cedilla normalization
Complete Chainable Methods Reference
Advanced Method Chaining Examples
Laravel Integration
Cache Management
Blasp uses Laravel's cache system to improve performance. The package automatically caches profanity expressions and their variations. To clear the cache, you can use the provided Artisan command:
This command will clear all cached Blasp expressions and configurations.
β‘ Performance
Blasp v3.0 includes significant performance optimizations:
- Cached Expression Sorting: Profanity expressions are sorted once and cached, eliminating repeated O(n log n) operations
- Hash Map Lookups: False positive checking and unique profanity tracking use O(1) hash map lookups instead of O(n) linear searches
- Optimized Regular Expressions: Improved regex generation and matching algorithms
- Intelligent Caching: Multi-layer caching system with automatic cache invalidation
Benchmarks
Version 3.0 shows substantial performance improvements over v2:
- Expression Processing: 60% faster profanity expression generation
- Detection Speed: 40% faster text analysis with large profanity lists
- Memory Usage: 30% reduction in memory footprint
- Cache Efficiency: 80% fewer database/config queries with intelligent caching
π Migration from v2.x to v3.0
100% Backward Compatible
All existing v2.x code continues to work without any changes:
New Features in v3.0
Take advantage of the simplified API:
π¨ Custom Masking
Using Custom Mask Characters
You can customize how profanities are masked using the maskWith()
method:
Setting Default Mask Character
You can set a default mask character in the configuration:
Combining with Other Methods
The maskWith()
method can be chained with other methods:
ποΈ Architecture
Blasp v3.0 follows SOLID principles and modern PHP practices:
- Facade Pattern: Simplified API with Laravel facade integration
- Builder Pattern: Method chaining for fluent interface
- Strategy Pattern: Language-specific detection and normalization
- Dependency Injection: Full Laravel service container integration
- Caching: Intelligent performance optimization
π Requirements
- PHP 8.1+
- Laravel 10.0+
- BCMath PHP Extension (for advanced calculations)
π€ 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.