- Does beastphp/easy-geetest work with Laravel 9 or 10?
- The package supports PHP 7.1+, but Laravel 9/10 require PHP 8.x. You’ll need to manually update type hints or use a compatibility layer. Test thoroughly, as the last release (2018) may lack Laravel 8+ features like named arguments or strict typing.
- How do I integrate Geetest CAPTCHA into Laravel login forms?
- Register the Geetest client as a singleton in Laravel’s service container, then inject it into controllers or create a custom validation rule. Use middleware to enforce CAPTCHA checks on login routes. Example: `app(Geetest::class)->successVerify($request->input('geetest_challenge'), ...)`.
- Are Geetest API keys securely stored in this package?
- No, the package doesn’t enforce secure storage. Store keys in Laravel’s `.env` file (e.g., `GEETEST_SECRET_ID`) and use `config()` to access them. Avoid hardcoding credentials in your application code or version control.
- What happens if Geetest’s API changes after 2018?
- The package may break due to undocumented API updates. Compare Geetest’s current API docs with the 2018 version and fork the package if needed. Consider wrapping API calls in a service layer to isolate changes.
- Can I use this package for API endpoints instead of forms?
- Yes, but you’ll need to manually handle CAPTCHA validation in API requests. Use Laravel’s `ValidateCaptcha` trait or custom rules to verify `geetest_challenge`, `geetest_validate`, and `geetest_seccode` in incoming requests.
- Is there built-in support for Laravel’s validation system?
- No, you’ll need to create a custom validation rule (e.g., `ValidateGeetest`) or middleware. Example: `return $geetest->successVerify($request->geetest_challenge, $request->geetest_validate, $request->geetest_seccode);`.
- What alternatives exist for Geetest in Laravel?
- Consider `laravel-captcha` (simple), `mll-laravel-captcha` (reCAPTCHA), or Geetest’s official PHP SDK if it’s updated. Alternatives like hCaptcha or Cloudflare Turnstile may offer better maintenance and Laravel integration.
- How do I handle failed CAPTCHA submissions in production?
- Implement retries with user feedback (e.g., `withErrors(['captcha' => 'Invalid CAPTCHA'])`). Log failed attempts to monitor abuse. For APIs, return HTTP 422 with error details. Consider rate-limiting to prevent brute-force attacks.
- Does this package support Geetest’s v4 API?
- Unlikely, as the package was last updated in 2018. Check Geetest’s API docs for v4 changes (e.g., `preProcess` → `validate`). You may need to fork the package or use Geetest’s official SDK if available.
- How do I test CAPTCHA validation in Laravel’s test suite?
- Mock the Geetest client using Laravel’s `Mockery` or `PHPUnit`. Example: `$this->mock(Geetest::class)->shouldReceive('successVerify')->andReturn(true);`. Test both valid and invalid CAPTCHA scenarios with assertions for redirects or validation errors.