captcha-laravel maintained by zhylon
Description
Laravel integration for server-side verification of Zhylon Captcha tokens.
Author
Last update
2026/08/23 22:00
(dev-main)
License
Downloads
1
Tags
captcha-laravel
Laravel integration for server-side verification of Zhylon Captcha tokens. Built on top of zhylon/captcha-php.
Requirements
- PHP 8.2+
- Laravel 12.x or 13.x
Installation
composer require zhylon/captcha-laravel
Publish the config file:
php artisan vendor:publish --tag=config
Set your secret key in .env:
ZHYLON_CAPTCHA_SITE_KEY=your-site-key
ZHYLON_CAPTCHA_SECRET_KEY=your-secret-key
Usage
Via the Captcha facade:
use Zhylon\CaptchaLaravel\Facades\Captcha;
$result = Captcha::verify($request->input('captcha_token'));
if (! $result->success) {
// $result->reason is one of: invalid_token, config_error, network_error
// $result->message contains a human-readable explanation
abort(403, $result->message);
}
Or inject Zhylon\CaptchaPhp\CaptchaClient wherever you need it — it's bound as a singleton in the container.
Config
| Key | Env variable | Default | Description |
|---|---|---|---|
site_key |
ZHYLON_CAPTCHA_SITE_KEY |
— | Your Zhylon Captcha site key |
secret_key |
ZHYLON_CAPTCHA_SECRET_KEY |
— | Your Zhylon Captcha secret key |
verify_url |
ZHYLON_CAPTCHA_VERIFY_URL |
https://captcha.zhylon.net/captcha/siteverify |
Verification endpoint |
timeout |
ZHYLON_CAPTCHA_TIMEOUT |
5 |
Request timeout in seconds |
CaptchaResult
| Property | Type | Description |
|---|---|---|
success |
bool |
Whether verification succeeded |
reason |
?string |
invalid_token, config_error, or network_error on failure |
message |
?string |
Human-readable explanation |
Use $result->isTechnicalFailure() to distinguish infrastructure problems (config_error, network_error) from a genuinely invalid token.
Testing
composer test
License
The MIT License (MIT). See LICENSE for more information.