PHP code example of teampanfu / laravel-hcaptcha

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

    

teampanfu / laravel-hcaptcha example snippets


'providers' => [
    ...

    /*
     * Package Service Providers...
     */
    Panfu\Laravel\HCaptcha\HCaptchaServiceProvider::class,

    ...
],

'aliases' => [
    ...
    'HCaptcha' => Panfu\Laravel\HCaptcha\Facades\HCaptcha::class,
    ...
],

$request->validate([
    'h-captcha-response' => ['hcaptcha'],
]);

'custom' => [
    'h-captcha-response' => [
        'hcaptcha' => 'Please verify that you are human.',
    ]
],



anfu\Laravel\HCaptcha\HCaptcha;

$sitekey = '10000000-ffff-ffff-ffff-000000000001';
$secret = '0x0000000000000000000000000000000000000000';
$hCaptcha = new HCaptcha($sitekey, $secret);

if (! empty($_POST)) {
    var_dump($hCaptcha->validate($_POST['h-captcha-response']));
    exit;
}

sh
php artisan vendor:publish --provider="Panfu\Laravel\HCaptcha\HCaptchaServiceProvider"
blade
{!! HCaptcha::display() !!}
blade
{!! HCaptcha::display([
    'class' => $errors->has('email') ? 'is-invalid' : '',
]) !!}
blade
{!! HCaptcha::script($locale, $render, $onload, $recaptchacompat) !!}