- Does Recaptcher support Google reCAPTCHA v3 (score-based) or only v2?
- Recaptcher currently only supports reCAPTCHA v2 (legacy) as it’s based on an outdated 2010 PHP library. Google recommends v3 for modern use, which requires a different API approach. The package has no roadmap for v3 support, so you’d need to fork or use an alternative like `bestmomo/laravel-recaptcha` for v3.
- How do I integrate Recaptcher with Laravel’s Validator for form validation?
- Use Laravel’s `Validator::extend()` to create a custom `recaptcha` rule. Instantiate the `Recaptcher` class via Laravel’s service container and call its `verify()` method in the validation callback. Example: `$validator->extend('recaptcha', fn($value) => app(Recaptcher::class)->verify($value));`
- Is Recaptcher actively maintained? What are the risks of using it?
- No, the package has no updates or dependents since 2016. Risks include breaking changes if Google’s API evolves (e.g., rate limits, v3 deprecation) or security vulnerabilities in the outdated base library. Always fork or monitor for forks if critical for production.
- Can I use Recaptcher with Laravel’s FormRequest validation?
- Yes, but you’ll need to manually bind the `Recaptcher` class to Laravel’s container in a service provider. Then, use the custom `recaptcha` validator in your `FormRequest` rules, like `['g-recaptcha-response' => 'required|recaptcha']`.
- Does Recaptcher handle API timeouts or rate limits?
- No, the package lacks built-in timeout or rate-limit handling. For production, wrap the `verify()` call in a try-catch block and implement retries or fallback logic. Google’s v2 API has a 1000-requests-per-minute limit, so high-traffic apps may need caching or queueing.
- How do I secure my reCAPTCHA API keys in Laravel?
- Store keys in Laravel’s `.env` file (e.g., `RECAPTCHA_SECRET`) and inject them via the `Recaptcher` constructor. The package doesn’t enforce this, so you’ll need to manually pass the keys or extend the class to read from config.
- Are there alternatives to Recaptcher for Laravel?
- Yes. For v2, consider `bestmomo/laravel-recaptcha` (actively maintained). For v3, use Google’s [official PHP client](https://github.com/googleapis/google-api-php-client) or `spatie/laravel-recaptcha`. These handle modern APIs, caching, and Laravel integration better.
- Will Recaptcher work with Laravel 10+ and PHP 8.1+?
- The package supports PHP 7.4+ and has no Laravel-specific dependencies, so it *should* work with Laravel 10+. However, test thoroughly—unmaintained packages may silently fail with newer PHP features or strict typing.
- How do I customize error messages for failed reCAPTCHA validation?
- Extend Laravel’s `Validator` to map reCAPTCHA errors (e.g., invalid key, timeout) to user-friendly messages. Example: `$validator->errors()->add('g-recaptcha-response', 'Invalid CAPTCHA. Please try again.');` after calling `verify()`.
- Does Recaptcher support localization (e.g., German, French) for reCAPTCHA?
- Yes, the package supports the `lang` option (e.g., `en`, `de`) via the constructor. Pass the language code dynamically from Laravel’s config or user locale, like `new Recaptcher($secret, $siteKey, app()->getLocale());`.