Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

No Captcha Laravel Package

anhskohbo/no-captcha

Laravel package to integrate Google reCAPTCHA “No CAPTCHA” into your app. Provides helpers to render the JS, display normal or invisible widgets, and validate responses. Supports Laravel auto-discovery, with simple .env configuration for site key and secret.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel-Native Design: Leverages Laravel’s service providers, facades, and auto-discovery (Laravel 5.5+), ensuring tight integration with existing ecosystems (e.g., validation, middleware, Blade). The facade pattern (NoCaptcha::verify(), NoCaptcha::renderJs()) aligns with Laravel’s idiomatic approach, reducing cognitive load for developers.
  • Modular Security Layer: Decouples CAPTCHA logic from business logic, enabling granular application (e.g., per-form, per-route, or per-user-group). Supports both explicit (visible widget) and invisible (v3 scoring) reCAPTCHA modes, accommodating diverse UX/security tradeoffs.
  • Validation System Integration: Extends Laravel’s validator with a captcha rule, centralizing bot-mitigation logic. This reduces duplication and ensures consistency across forms/APIs.
  • Configuration-Driven: Centralized .env settings (NOCAPTCHA_SECRET, NOCAPTCHA_SITEKEY) and publishable config files enable environment-specific tuning (e.g., staging vs. production thresholds).

Integration Feasibility

  • Composer-First: Zero-dependency installation (composer require anhskohbo/no-captcha) with auto-discovery in Laravel 5.5+, eliminating manual service provider/alias registration for modern stacks.
  • Frontend-Backend Sync:
    • Frontend: Blade directives ({!! NoCaptcha::renderJs() !!}, {!! NoCaptcha::display() !!}) or JavaScript inclusion for dynamic rendering. Supports custom attributes (e.g., data-theme="dark") and invisible reCAPTCHA via displaySubmit().
    • Backend: Seamless validation via NoCaptcha::verifyResponse($token) or Laravel’s validator ('g-recaptcha-response' => 'required|captcha'). API routes can use middleware for token validation.
  • Laravel Version Compatibility:
    • Supported: Laravel 5–12 (with explicit version branches). Teams on unsupported versions (e.g., Lumen, Laravel 4) may require minor adaptations (e.g., manual service binding).
    • Future-Proofing: Active maintenance (last release: 2026-04-01) with clear upgrade paths for new Laravel versions.
  • Testing Support: Built-in mocking for unit/HTTP tests (NoCaptcha::shouldReceive('verifyResponse')->andReturn(true)), reducing flakiness in CI/CD pipelines.

Technical Risk

  • Google API Dependencies:
    • Rate Limits: Free tier caps at 1M requests/day. High-traffic apps risk throttling without monitoring/caching. Mitigation:
      • Implement client-side caching of reCAPTCHA tokens (e.g., store valid tokens for 24h).
      • Use reCAPTCHA v3’s score threshold to reduce API calls for low-risk submissions.
    • API Changes: Google may deprecate endpoints or modify responses. Mitigation:
    • Privacy/Compliance: GDPR/CCPA may require disclosures about Google’s data collection. Mitigation:
      • Add a privacy notice (e.g., "This site uses reCAPTCHA to protect against spam").
      • Consider hCaptcha or Cloudflare Turnstile if data sovereignty is critical.
  • JavaScript Reliance:
    • Ad Blockers: Users with ad blockers may disable reCAPTCHA scripts. Mitigation:
      • Implement a fallback (e.g., manual CAPTCHA or rate-limiting via throttle middleware).
      • Test with ad blockers (e.g., uBlock Origin) in QA.
    • Performance: Additional HTTP request to Google’s CDN (~200ms latency). Mitigation:
      • Load reCAPTCHA asynchronously or defer until form submission.
      • Use reCAPTCHA v3’s invisible mode for high-traffic forms.
  • Validation Edge Cases:
    • Non-Form Submissions: AJAX/WebSocket/CLI submissions may lack g-recaptcha-response. Mitigation:
      • Add middleware to validate tokens on API routes (e.g., VerifyRecaptcha::class).
      • Document requirements for frontend teams (e.g., "Include g-recaptcha-response in all form submissions").
    • Custom Validation: Advanced use cases (e.g., dynamic thresholds, multi-step forms) may require extensions. Mitigation:
      • Extend the package via traits or create a wrapper class.
      • Use middleware to pre-validate tokens before form processing.

Key Questions

  1. Security Requirements:
    • Does the app handle high-stakes transactions (e.g., payments, healthcare data) where reCAPTCHA’s accuracy may be insufficient? If so, consider multi-factor CAPTCHA (e.g., combine with rate-limiting or device fingerprinting).
    • Are there compliance constraints (e.g., no third-party CAPTCHAs)? If yes, evaluate alternatives like hCaptcha or custom puzzles.
  2. Traffic Volume:
    • Will the app exceed 1M reCAPTCHA requests/day? If so, budget for Google’s paid tier or implement caching.
    • Are there cost-sensitive regions (e.g., high-traffic but low-revenue markets)? Consider region-specific thresholds (e.g., disable reCAPTCHA for low-risk countries).
  3. User Experience:
    • Should reCAPTCHA be visible or invisible? Invisible (v3) reduces friction but may increase false positives for legitimate users.
    • Are there localization needs (e.g., 20+ languages)? The package supports this via NoCaptcha::renderJs('fr'), but test performance for non-Latin scripts.
  4. Maintenance:
    • Who will monitor Google API changes and update the package? Assign a tech lead or set up dependency alerts.
    • Is there a fallback plan if reCAPTCHA fails (e.g., manual review, rate-limiting)?
  5. Testing:
    • How will flakiness in CI/CD be handled? Use the provided mocking utilities and add pre-commit hooks to validate reCAPTCHA responses.
    • Are there performance benchmarks for reCAPTCHA load times? Test with tools like Lighthouse or WebPageTest.

Integration Approach

Stack Fit

  • Laravel Ecosystem: Optimized for Laravel 5–12, with auto-discovery in 5.5+. Integrates natively with:
    • Validation: required|captcha rules.
    • Middleware: Custom middleware for API route protection.
    • Blade: Directives for rendering widgets ({!! NoCaptcha::display() !!}).
    • Testing: Mocking utilities for unit/HTTP tests.
  • Frontend Agnostic: Works with:
    • Blade templates: Native support via facades.
    • JavaScript frameworks (React/Vue): Manually include the reCAPTCHA script and submit the token via g-recaptcha-response.
    • APIs: Validate tokens in middleware or controllers.
  • Non-Laravel PHP: Supports standalone PHP via the NoCaptcha class (see usage example), though without Laravel’s conveniences.

Migration Path

  1. Assessment Phase:
    • Audit forms/APIs requiring bot protection (e.g., signups, comments, contact forms).
    • Identify high-risk vs. low-risk submission paths (e.g., payments vs. newsletters).
    • Document current CAPTCHA (if any) and its limitations.
  2. Pilot Integration:
    • Start with a low-traffic form (e.g., blog comments) to test:
      • Rendering (NoCaptcha::display()).
      • Validation ('g-recaptcha-response' => 'required|captcha').
      • Error handling (custom messages in resources/lang/en/validation.php).
    • Monitor conversion rates and bot reduction (e.g., via Google Analytics or spam filters).
  3. Gradual Rollout:
    • Phase 1: Add reCAPTCHA to non-critical forms (e.g., contact us, newsletter signup).
    • Phase 2: Enable for high-volume but low-risk forms (e.g., account creation).
    • Phase 3: Apply to high-risk forms (e.g., checkout, password resets) using invisible reCAPTCHA (v3).
  4. Fallback Implementation:
    • Add middleware to rate-limit or disable submissions if reCAPTCHA fails (e.g., abort_if in Laravel).
    • Implement a manual review queue for submissions without valid tokens.

Compatibility

  • Laravel Versions:
    • **
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope