PHP code example of particle-academy / fancy-captcha
1. Go to this page and download the library: Download particle-academy/fancy-captcha 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/ */
particle-academy / fancy-captcha example snippets
Route::post('/register', RegisterController::class)->middleware('captcha:signup');
use FancyCaptcha\Rules\Captcha;
public function rules(): array
{
return ['email' => ['
[
'provider' => 'builtin', // or turnstile, recaptcha-v2, recaptcha-v3, hcaptcha
'siteKey' => null, // the PUBLIC key only; never a secret
'action' => null,
'fields' => ['honeypot' => 'contact_fax', 'started' => '_captcha_started', 'pow' => '_captcha_pow', 'token' => '_captcha_token'],
'started' => '1762344000.Qm9...', // signed render time
'pow' => ['enabled' => false, 'difficulty' => 18, 'challengeUrl' => '/fancy-captcha/challenge'],
'consentCategory' => null,
'configured' => true,
]
'consent' => ['category' => 'functional', 'fallback_pow' => true],
use FancyCaptcha\Facades\Captcha;
$fake = Captcha::fake(); // every verification passes
$this->post('/register', [...])->assertRedirect('/home');
$fake->assertVerified('signup');
Captcha::fake(passes: false); // every verification fails
$fake->fails(); $fake->passes(); // switch mid-test
$fake->assertNotVerified();
$fake->assertVerifiedCount(1);
Captcha::extend('friendly', fn ($app, array $config) => new FriendlyVerifier($config));