Download the PHP package gkcaptcha/gkcaptcha-laravel without Composer
On this page you can find all versions of the php package gkcaptcha/gkcaptcha-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gkcaptcha/gkcaptcha-laravel
More information about gkcaptcha/gkcaptcha-laravel
Files in gkcaptcha/gkcaptcha-laravel
Package gkcaptcha-laravel
Short Description Laravel integration for gkCAPTCHA: middleware, validation rule, Blade directive, and service provider
License MIT
Homepage https://gatekeeper.sa
Informations about the package gkcaptcha-laravel
gkcaptcha-laravel
Laravel integration package for gkCAPTCHA. Provides a service provider, middleware, validation rule, Blade directive, and Facade for CAPTCHA protection with a single line of configuration.
Requirements
- PHP 8.1+
- Laravel 10 or 11
gkcaptcha/gkcaptcha-php^1.0 (included as a dependency)
Installation
The package auto-discovers via Laravel's package auto-discovery. No manual registration required.
Configuration
Publish the config file:
Add to .env:
Environment Variables
| Variable | Default | Description |
|---|---|---|
GKCAPTCHA_SECRET_KEY |
(required) | Server-side secret key for token verification |
GKCAPTCHA_SITE_KEY |
(required) | Public site key for the widget |
GKCAPTCHA_API_URL |
https://gkcaptcha.gatekeeper.sa |
gkCAPTCHA API base URL |
GKCAPTCHA_TIMEOUT |
5.0 |
Request timeout in seconds |
GKCAPTCHA_FAIL_CLOSED |
false |
Block requests on network error (fail-closed) |
GKCAPTCHA_WIDGET_URL |
https://gkcaptcha.gatekeeper.sa/widget/gk-captcha.js |
Widget script URL |
Blade Directive
Add the CAPTCHA widget to any Blade template:
If GKCAPTCHA_SITE_KEY is set in .env, you can omit the argument:
The directive outputs:
Middleware
Route Group (recommended)
Protect a group of routes by adding VerifyCaptcha to a route group:
Global Kernel Registration (Laravel 10)
In app/Http/Kernel.php:
Then use the alias:
Token Sources
The middleware reads the CAPTCHA token from (in priority order):
captchaTokenbody field (form POST or JSON body)X-Captcha-Tokenrequest header (AJAX / API)
Middleware Responses
| Condition | HTTP Status | Body |
|---|---|---|
| No token present | 403 | {"success": false, "error": "CAPTCHA token required"} |
| Token invalid | 403 | {"success": false, "error": "CAPTCHA verification failed"} |
| Network error (fail-open) | passes through | Warning logged, request continues |
| Token valid | passes through | Normal route response |
Validation Rule
Use the gkcaptcha rule in form request classes or inline validators:
Or with the Rule object directly:
Facade
For inline verification anywhere in your application:
Fail-Open Behavior
By default (GKCAPTCHA_FAIL_CLOSED=false), network errors when reaching the gkCAPTCHA API allow the request to proceed. A warning is logged:
This prevents gkCAPTCHA API availability from causing downtime on your application.
Set GKCAPTCHA_FAIL_CLOSED=true to block requests when the API is unreachable. This is appropriate for high-security environments where it is better to reject users than to risk allowing bots through.
Testing
The package includes PHPUnit-compatible tests using Orchestra Testbench.
With dependencies installed:
For environments without Composer (CI, Docker images without Testbench), a standalone runner is included:
License
MIT
All versions of gkcaptcha-laravel with dependencies
gkcaptcha/gkcaptcha-php Version ^0.1
illuminate/support Version ^10.0|^11.0