PHP code example of fet / laminas-cloudflare-turnstile

1. Go to this page and download the library: Download fet/laminas-cloudflare-turnstile 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/ */

    

fet / laminas-cloudflare-turnstile example snippets


return [
    'modules' => [
        // ... other modules ...
        'Fet\\LaminasCloudflareTurnstile',
    ],
];

$form = new \Laminas\Form\Form('my-form');
$form->add([
    'name' => 'captcha',
    'type' => \Laminas\Form\Element\Captcha::class,
    'options' => [
        'captcha' => new \Fet\LaminasCloudflareTurnstile\TurnstileCaptcha([
            'site_key' => getenv('CLOUDFLARE_TURNSTILE_SITE_KEY'),
            'secret_key' => getenv('CLOUDFLARE_TURNSTILE_SECRET_KEY'),
        ]),
    ]
]);
html
<?= $this->form($this->form);