fet / laminas-cloudflare-turnstile
An implementation of cloudflare turnstile for Laminas applications.
0.1.0
2025-04-25 08:03 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.9
- laminas/laminas-captcha: ^2.18
- laminas/laminas-form: ^3.21
- laminas/laminas-i18n: ^2.30
- laminas/laminas-mvc: ^3.8
- laminas/laminas-servicemanager: ^3.4
- laminas/laminas-view: ^2.36
Requires (Dev)
- mockery/mockery: ^1.6
- nunomaduro/phpinsights: ^2.11
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5
README
The fet/laminas-cloudflare-turnstile
package provides a Cloudflare turnstile widget integration for Laminas forms.
Installation
To install this package, use Composer:
composer require fet/laminas-cloudflare-turnstile
Enable the Fet\\LaminasCloudflareTurnstile
module in your config/application.config.php
file.
return [ 'modules' => [ // ... other modules ... 'Fet\\LaminasCloudflareTurnstile', ], ];
Usage
You can add the turnstile adapter via the captcha
option to your form and render the element in your view.
Form
$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'), ]), ] ]);
View
<?= $this->form($this->form); ?> <!-- or --> <?= $this->formElement($this->form->get('captcha')); ?> <?= $this->formElementErrors($this->form->get('captcha')); ?>
Tests
Run the tests with:
composer test