beastphp/easy-geetest
EasyGeetest PHP SDK for integrating Geetest CAPTCHA with modern PHP (>=7.1). Composer-ready, namespaced wrapper based on the official SDK. Instantiate with captcha_id/private_key and call successValidate with challenge/validate/seccode plus optional user/client/ip info.
beastphp/easy-geetest) provides a PHP SDK for integrating Geetest (极验), a CAPTCHA service, into Laravel applications. It aligns well with security-focused Laravel projects requiring CAPTCHA validation (e.g., login forms, API endpoints, or form submissions).laravel-captcha) or third-party packages like mll-laravel-captcha. This package’s niche is Geetest-specific integration, which may be justified for compliance or legacy system requirements.ValidateCaptcha trait or custom rules).geetest/geetest-php-sdk).laravel-package-discovery) to load the package as a service provider.$this->app->singleton(Geetest::class, function ($app) {
return new \EasyGeetest\Geetest($app['config']['geetest']);
});
preProcess with validate calls..env:
GEETEST_SECRET_ID=your_secret_id
GEETEST_CAPTCHA_ID=your_captcha_id
php artisan vendor:publish --provider="EasyGeetest\ServiceProvider"
use EasyGeetest\Geetest;
class ValidateGeetest extends FormRequest
{
public function validateCaptcha()
{
$geetest = app(Geetest::class);
return $geetest->successVerify($this->input('geetest_challenge'), $this->input('geetest_validate'), $this->input('geetest_seccode'));
}
}
public function handle($request, Closure $next)
{
if (!$request->hasValidCaptcha()) {
return redirect()->back()->withErrors(['captcha' => 'Invalid CAPTCHA']);
}
return $next($request);
}
$request->validate()) or form requests to integrate CAPTCHA checks.captcha.failed) for analytics or notifications.composer.json to avoid unintended updates:
"beastphp/easy-geetest": "dev-maintainer-fork"
phpstan or psalm).GEETEST_DEBUG in config).$geetest->setDebug(true); // Enable if supported
geetest:validate-job).throttle middleware).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Geetest API downtime | CAPTCHA validation fails | Fallback to manual review or disable CAPTCHA |
| API key leakage | Security breach | Rotate keys; use Laravel’s env encryption |
| Package incompatibility | Broken CAPTCHA flow | Fork and maintain the package |
| High latency in API calls | Poor UX | Implement caching or async validation |
docs/geetest-integration.md).// Example: Validate CAPTCHA in a controller
public function submitForm(Request $request)
{
$geetest = app(Geetest::class);
if (!$geetest->successVerify($request->geetest_challenge, $request->geetest_validate, $request->geetest_seccode)) {
return back()->withErrors(['captcha' => 'Invalid']);
}
// Proceed with form submission
}
How can I help you explore Laravel packages today?