PHP code example of cboxdk / laravel-risk

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

    

cboxdk / laravel-risk example snippets


use Cbox\Risk\Facades\Risk;
use Cbox\Risk\ValueObjects\RiskContext;

$assessment = Risk::assess(RiskContext::fromRequest($request, action: 'register', attributes: [
    'honeypot' => $request->input('nickname'),        // an invisible field
    'form_rendered_at' => $request->integer('rendered_at'),
]));

if ($assessment->atLeast(Outcome::Challenge)) {
    // show a CAPTCHA, 

// routes/console.php
Schedule::command('risk:refresh-ipsum')->daily();

final class GeoVelocitySignal implements Signal
{
    public function key(): string { return 'geo.velocity'; }

    public function evaluate(RiskContext $context): ?SignalResult
    {
        // return new SignalResult('geo.velocity', 30, 'impossible travel') or null
    }
}