PHP code example of fidelo-software / laravel-spamshield

1. Go to this page and download the library: Download fidelo-software/laravel-spamshield 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/ */

    

fidelo-software / laravel-spamshield example snippets


$spamshield = new \FideloSoftware\Spam\SpamShield(
    [
        new \FideloSoftware\Spam\Strategies\HoneypotStrategy(3),
        new \FideloSoftware\Spam\Strategies\TimestampStrategy($store, 5),
        new \FideloSoftware\Spam\Strategies\LinkStrategy(0),
        new \FideloSoftware\Spam\Strategies\ValueBlacklistStrategy(['name' => ['John Doe']]),
    ], 
    $store
    $logger // optional
);

// Form initialization 
$spamshield->onload($form, $request);

// Form rendering
echo $spamshield->html($form);

// Submit
try {
    $spamshield->detect($form, $request);
} catch(\FideloSoftware\Spam\Exceptions\BannedException $e) {
    ...
} catch(\FideloSoftware\Spam\Exceptions\SpamDetectionException $e) {
    ...
}

// Check if user is globally banned after to many attempts
\FideloSoftware\Spam\SpamShield::isBanned($store, $request);