1. Go to this page and download the library: Download blaspsoft/blasp library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
blaspsoft / blasp example snippets
use Blaspsoft\Blasp\Facades\Blasp;
// Simple usage - uses default language from config
$result = Blasp::check('This is a fucking shit sentence');
// With method chaining for specific language
$result = Blasp::spanish()->check('esto es una mierda');
// Check against ALL languages at once
$result = Blasp::allLanguages()->check('fuck merde scheiße mierda');
// Language shortcuts
Blasp::english()->check($text);
Blasp::spanish()->check($text);
Blasp::german()->check($text);
Blasp::french()->check($text);
// Check against all languages
Blasp::allLanguages()->check($text);
// Custom mask character
Blasp::maskWith('#')->check($text);
Blasp::maskWith('●')->check($text);
// Configure custom profanities
Blasp::configure(['badword'], ['goodword'])->check($text);
// Chain multiple methods together
Blasp::spanish()->maskWith('*')->check($text);
Blasp::allLanguages()->maskWith('-')->check($text);
$result = Blasp::check('This is fucking awesome');
$result->getSourceString(); // "This is fucking awesome"
$result->getCleanString(); // "This is ******* awesome"
$result->hasProfanity(); // true
$result->getProfanitiesCount(); // 1
$result->getUniqueProfanitiesFound(); // ['fucking']
// With custom mask character
$result = Blasp::maskWith('#')->check('This is fucking awesome');
$result->getCleanString(); // "This is ####### awesome"
$request->merge(['sentence' => 'This is f u c k 1 n g awesome!']);
$validated = $request->validate([
'sentence' => ['blasp_check'],
]);
// With language specification
$validated = $request->validate([
'sentence' => ['blasp_check:spanish'],
]);
// config/blasp.php
return [
'default_language' => 'english', // Default language for detection
'mask_character' => '*', // Default character for masking profanities
'separators' => [...], // Special characters used as separators
'substitutions' => [...], // Character substitutions (like @ for a)
'false_positives' => [...], // Words that should not be flagged
];
use Blaspsoft\Blasp\Facades\Blasp;
$blasp = Blasp::configure(
profanities: $your_custom_profanities,
falsePositives: $your_custom_false_positives
)->check($text);
// Check text against ALL configured languages at once
$result = Blasp::allLanguages()->check('fuck merde scheiße mierda');
// Detects profanities from English, French, German, and Spanish
// Get detailed results
echo $result->getProfanitiesCount(); // 4
echo $result->getUniqueProfanitiesFound(); // ['fuck', 'merde', 'scheiße', 'mierda']
// Language selection methods
Blasp::language('spanish') // Set any language by name
Blasp::english() // Shortcut for English
Blasp::spanish() // Shortcut for Spanish
Blasp::german() // Shortcut for German
Blasp::french() // Shortcut for French
Blasp::allLanguages() // Check against all languages
// Configuration methods
Blasp::configure($profanities, $falsePositives) // Custom word lists
Blasp::maskWith('#') // Custom mask character
// Detection method
Blasp::check($text) // Analyze text for profanities
// All methods return BlaspService for chaining
$service = Blasp::spanish() // Returns BlaspService
->maskWith('●') // Returns BlaspService
->configure(['custom'], ['false_positive']) // Returns BlaspService
->check('texto para verificar'); // Returns BlaspService with results
// Example 1: Spanish with custom mask
Blasp::spanish()
->maskWith('#')
->check('esto es una mierda');
// Result: "esto es una ######"
// Example 2: All languages with custom configuration
Blasp::allLanguages()
->configure(['newbadword'], ['safephrase'])
->maskWith('-')
->check('multiple fuck merde languages');
// Result: "multiple ---- ----- languages"
// Example 3: Dynamic language selection
$language = $user->preferred_language; // 'french'
Blasp::language($language)
->maskWith($user->mask_preference ?? '*')
->check($userContent);
// Laravel service container integration
$blasp = app(BlaspService::class);
// Validation rule with default language
$request->validate([
'message' => '
// Existing code works exactly the same
use Blaspsoft\Blasp\Facades\Blasp;
$result = Blasp::check('text to check');
$result = Blasp::configure($profanities, $falsePositives)->check('text');
// NEW: Method chaining
Blasp::spanish()->check($text);
// NEW: All languages detection
Blasp::allLanguages()->check($text);
// NEW: Language shortcuts
Blasp::german()->check($text);
Blasp::french()->check($text);
// NEW: Custom mask characters
Blasp::maskWith('#')->check($text);
Blasp::spanish()->maskWith('●')->check($text);
// NEW: Default language configuration
// Set in config/blasp.php: 'default_language' => 'spanish'
Blasp::check($text); // Now uses Spanish by default
// Use hash symbols instead of asterisks
$result = Blasp::maskWith('#')->check('This is fucking awesome');
echo $result->getCleanString(); // "This is ####### awesome"
// Use dots for masking
$result = Blasp::maskWith('·')->check('What the hell');
echo $result->getCleanString(); // "What the ····"
// Unicode characters work too
$result = Blasp::maskWith('●')->check('damn it');
echo $result->getCleanString(); // "●●●● it"
// config/blasp.php
return [
'mask_character' => '#', // All profanities will be masked with #
// ...
];
// Spanish text with custom mask
Blasp::spanish()->maskWith('@')->check('esto es mierda');
// All languages with dots
Blasp::allLanguages()->maskWith('·')->check('multilingual text');
// Configure and mask
Blasp::configure(['custom'], [])
->maskWith('-')
->check('custom text');
bash
php artisan blasp:clear
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.