PHP code example of enjoys / forms-recaptcha

1. Go to this page and download the library: Download enjoys/forms-recaptcha 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/ */

    

enjoys / forms-recaptcha example snippets

 
// ...before code
// Optional. Set ID for form (for V2Invisible and V3) 
$form->setAttribute(AttributeFactory::create('id', uniqid()));
// Init reCaptcha
$captcha = new reCaptcha($Psr18_HttpClient, $Psr7RequestFactory, $Psr7StreamFactory);

$captcha->setOptions([
    'type' => V3::class, //V2Invisible, V2, V3
    'publicKey' => '...',
    'privateKey' => '...',
    'submitEl' => 'submit1',
    // more options ...
]);

$form->captcha($captcha);
$form->submit('submit1');
// more code...