The error occurs because biscolab/laravel-recaptcha does not yet support Laravel 12. The latest version (as of now, v6.1.0) only supports up to Laravel 11, according to its composer.json and Packagist page.
What you can do:
-
Wait for Official Support:
Monitor the biscolab/laravel-recaptcha GitHub repository for Laravel 12 support. You can check issues or pull requests for updates. -
Use an Alternative Package:
Consider using another package that supports Laravel 12, such as anhskohbo/no-captcha, which is widely used and may update faster. -
Implement reCAPTCHA Manually:
You can integrate Google reCAPTCHA yourself without a package. Here’s a basic example for reCAPTCHA v2:a. Add reCAPTCHA to your form:
<form method="POST" action="/your-form"> @csrf <!-- your form fields --> <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY"></div> <button type="submit">Submit</button> </form> <script src="https://www.google.com/recaptcha/api.js" async defer></script>b. Validate in your controller:
use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; public function submit(Request $request) { $request->validate([ // your validation rules 'g-recaptcha-response' => 'required', ]); $response = Http::asForm()->post('https://www.google.com/recaptcha/api/siteverify', [ 'secret' => 'YOUR_SECRET_KEY', 'response' => $request->input('g-recaptcha-response'), 'remoteip' => $request->ip(), ]); if (!$response->json('success')) { return back()->withErrors(['captcha' => 'reCAPTCHA verification failed.']); } // Continue processing } -
If You Must Use biscolab/laravel-recaptcha:
- You could try forking the package and updating its
composer.jsonto allow Laravel 12, but this is not recommended unless you are comfortable maintaining your own fork and fixing any breaking changes.
- You could try forking the package and updating its
Summary:
Currently, you cannot install biscolab/laravel-recaptcha on Laravel 12. Either wait for an update, use an alternative, or implement reCAPTCHA manually as shown above.