dario_swain/re-captcha-validator
Lightweight Google reCAPTCHA v2 form type and validator component for Symfony2. Not a bundle—fully configurable services. Install via Composer, set public/private keys, and register the ReCaptcha form type to validate submissions in your forms.
FormRequest, Validator, HTML helpers) and does not natively support Symfony’s FormType/Validator system.FormType, Validator, Twig themes) is incompatible with Laravel’s ecosystem.FormRequest validation would need to manually call Google’s reCAPTCHA API (v2 or v3) via Guzzle/cURL.g-recaptcha-response token.laravel-recaptcha, spatie/laravel-recaptcha) that are actively maintained and Symfony-agnostic.FormType/Validator logic in Laravel would introduce bugs, edge cases, and maintenance overhead.Why Symfony-Specific?
spatie/laravel-recaptcha)?API Version Alignment
Frontend/Backend Decoupling
g-recaptcha-response) be passed from Blade to Laravel’s backend?Maintenance Burden
Alternatives Assessment
spatie/laravel-recaptcha or laravel-recaptcha been evaluated for compatibility with the project’s needs?FormType/Validator system does not map to Laravel’s FormRequest, Validator, or HTML helpers.Validator with a custom Laravel validation rule or middleware.config/services.php (not Symfony’s parameters.yml).Assessment Phase:
spatie/laravel-recaptcha).Frontend Integration (Option B/C):
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
<input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response">
document.getElementById('submit-button').addEventListener('click', function() {
document.getElementById('g-recaptcha-response').value = grecaptcha.getResponse();
});
Backend Validation (Option B/C):
use Illuminate\Contracts\Validation\Rule;
use GuzzleHttp\Client;
class ReCaptchaRule implements Rule {
public function passes($attribute, $value) {
$client = new Client();
$response = $client->post('https://www.google.com/recaptcha/api/siteverify', [
'form_params' => [
'secret' => config('services.recaptcha.secret'),
'response' => $value,
],
]);
$data = json_decode($response->getBody(), true);
return $data['success'] ?? false;
}
}
FormRequest or controller:
$request->validate([
'g-recaptcha-response' => ['required', new ReCaptchaRule],
]);
Configuration:
.env:
RECAPTCHA_SITE_KEY=your_site_key
RECAPTCHA_SECRET_KEY=your_secret_key
spatie/laravel-recaptcha).FormComponent, ValidatorComponent, and Twig. These cannot be reused in Laravel.How can I help you explore Laravel packages today?