- How do I install and set up anhskohbo/no-captcha in Laravel 5.5+?
- Run `composer require anhskohbo/no-captcha`, then add your Google site and secret keys to `.env` under `NOCAPTCHA_SITEKEY` and `NOCAPTCHA_SECRET`. Laravel 5.5+ auto-discovers the package, so no manual `app.php` edits are needed.
- Does this package support invisible reCAPTCHA (v2)?
- Yes, use `NoCaptcha::displaySubmit('submitButtonId')` to render invisible reCAPTCHA tied to a specific form submit button. This is ideal for reducing visual clutter while maintaining bot protection.
- Can I use this package with Laravel 5.1–5.4 or Lumen?
- Yes, but you’ll need to manually register the service provider and facade in `app.php`. Lumen requires explicit service provider binding. For Laravel 5.1–5.4, also publish the config file with `php artisan vendor:publish`.
- How do I validate reCAPTCHA responses in Laravel forms?
- Add the `captcha` validation rule to your form request or controller. For example: `'g-recaptcha-response' => 'required|captcha'`. The package integrates natively with Laravel’s validation system.
- Will this package work with React/Vue.js frontends without Blade?
- No, this package relies on Blade helpers for rendering JS and widgets. For SPAs, use Inertia.js to render Blade components or expose a custom API endpoint to handle validation server-side.
- What if Google reCAPTCHA is blocked in certain regions (e.g., China)?
- Consider using a fallback like hCaptcha or implementing middleware to switch providers based on user location. The package’s facade can be extended to support alternative CAPTCHA services.
- How do I customize the reCAPTCHA widget (e.g., dark theme, size)?
- Pass an array of attributes to `NoCaptcha::display()`. For example: `NoCaptcha::display(['data-theme' => 'dark', 'data-size' => 'compact'])` to customize appearance and behavior.
- Does this package support language localization for reCAPTCHA?
- Yes, specify the language code when rendering JS: `NoCaptcha::renderJs('fr')` for French. Supported languages include `en`, `es`, `fr`, `de`, and more—check Google’s [language list](https://developers.google.com/recaptcha/docs/language).
- How can I test reCAPTCHA validation in CI/CD pipelines?
- Mock the `NoCaptcha` facade in tests using Laravel’s mocking helpers. For example: `NoCaptcha::shouldReceive('verifyResponse')->andReturn(true)`. This avoids hitting Google’s API during automated testing.
- What are the performance implications of loading Google’s reCAPTCHA script?
- Google’s script (~100KB) can impact page load time. Use `NoCaptcha::renderJs()` with lazy-loading or opt for invisible reCAPTCHA (`displaySubmit()`) to minimize performance overhead.