- How do I integrate captchaapi/laravel into a Laravel 13 project with Livewire?
- Install the package via Composer, publish the config, and add your site/secret keys to `.env`. Use the `WithCaptcha` trait in your Livewire component and wrap your form with `<x-captchaapi::livewire-form>`. The package provides a Livewire-native trait for seamless validation and widget rendering.
- Does this package work with Laravel 12 or older versions?
- No, this package requires Laravel 12 or 13 and PHP 8.2+. If you’re using an older Laravel version, you’ll need to upgrade or consider alternatives like hCaptcha or reCAPTCHA, which support broader Laravel versions.
- How do I disable CAPTCHA in development or staging environments?
- Set `CAPTCHAAPI_ENABLED=false` in your `.env` file. This disables all CAPTCHA checks without requiring code changes. The package respects this flag globally for all forms and Livewire components.
- What happens if the captchaapi.eu API fails during form submission?
- By default, the package uses `fail_open=true`, meaning submissions will pass if the API is unavailable. For critical actions (e.g., logins or payments), explicitly set `fail_open=false` in the config or handle failures manually in your validation logic.
- Can I use this package without Livewire, or is it required?
- Livewire support is optional. The package works perfectly with plain Blade forms. Use the `<x-captchaapi::widget />` component in your layout and add `data-captcha` to form fields. Livewire-specific features are only needed if you’re using Livewire 4+.
- Is there a way to customize the CAPTCHA widget’s appearance or behavior?
- The package provides basic customization via the config file (e.g., timeout, locale). For deeper styling, you can override the Blade component (`resources/views/vendor/captchaapi/widget.blade.php`) or use custom JavaScript to modify the widget’s behavior after initialization.
- How do I test CAPTCHA validation in my Laravel tests?
- Mock the CAPTCHA API responses using Laravel’s HTTP client or a testing helper like `Http::fake()`. Override the `CaptchaApi` facade or use the `ValidCaptcha` rule directly in your test assertions. Example: `Http::fake(['https://captchaapi.eu' => Http::response(['success' => true])]);`
- What are the pricing implications for high-traffic sites?
- captchaapi.eu uses a volume-based pricing model, which can become costly for high-traffic sites. Check their [dashboard](https://captchaapi.eu/dashboard) for current rates. For budget-sensitive projects, consider implementing a fallback (e.g., reCAPTCHA) or caching responses to reduce API calls.
- Does this package support multi-language or RTL (right-to-left) layouts?
- The package supports basic localization via the `locale` config option (e.g., `en`, `de`). For RTL layouts, ensure your frontend CSS handles the widget’s directionality, as the package itself doesn’t enforce RTL-specific styling. Test thoroughly in your target language.
- How does this compare to hCaptcha or reCAPTCHA for Laravel?
- Unlike hCaptcha or reCAPTCHA, captchaapi.eu is EU-hosted and GDPR-compliant by default, with no cookies or tracking. It’s also proof-of-work, making it invisible to legitimate users. However, it lacks the global adoption and fallback options of hCaptcha or reCAPTCHA, which may be critical for some projects.