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

Lara Core Laravel Package

sinarajabpour1998/lara-core

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package via Composer:

composer require vendor/package-name

Publish the configuration file (if available) and run migrations:

php artisan vendor:package publish --provider="Vendor\PackageName\PackageServiceProvider"
php artisan migrate

For Google reCAPTCHA, register your site keys in .env:

RECAPTCHA_SITE_KEY=your_site_key
RECAPTCHA_SECRET_KEY=your_secret_key

Use the reCAPTCHA validation in a form request:

use Vendor\PackageName\Http\Requests\RecaptchaValidatedFormRequest;

class MyFormRequest extends RecaptchaValidatedFormRequest
{
    public function rules()
    {
        return [
            'email' => 'required|email',
            // Other rules...
        ];
    }
}

Implementation Patterns

Form Validation

Extend RecaptchaValidatedFormRequest to auto-validate reCAPTCHA submissions:

// In your controller
public function store(MyFormRequest $request)
{
    // reCAPTCHA is validated automatically
    // Proceed with logic...
}

Manual Validation

Validate reCAPTCHA manually in controllers:

use Vendor\PackageName\Services\RecaptchaService;

public function submit(Request $request, RecaptchaService $recaptcha)
{
    if (!$recaptcha->verify($request->input('g-recaptcha-response'))) {
        return back()->withErrors(['recaptcha' => 'Invalid verification']);
    }
    // Proceed...
}

Dynamic Site Key

Override the default site key per request:

$recaptcha->verify($response, 'custom_site_key');

Integration with Views

Embed reCAPTCHA in Blade templates:

<div class="g-recaptcha" data-sitekey="{{ config('services.recaptcha.site_key') }}"></div>

Gotchas and Tips

Configuration

  • Ensure .env keys are set before first use (e.g., in bootstrap/app.php or AppServiceProvider).
  • Default config path: config/services.php (add recaptcha array if missing).

Debugging

  • Failed verification? Check:
    • Correct g-recaptcha-response field name in form submissions.
    • Valid secret_key in .env.
    • Network requests to https://www.google.com/recaptcha/api/siteverify (use browser dev tools).
  • Rate limits: Google enforces quota limits. Monitor usage in Google Admin Console.

Extension Points

  • Custom responses: Override RecaptchaService to modify error messages or logic:
    $recaptcha = app()->makeWith(RecaptchaService::class, [
        'customError' => 'Custom error message',
    ]);
    
  • Async verification: For high-traffic apps, consider queueing reCAPTCHA validation (e.g., using Laravel Queues).

Deprecations/BC Breaks

  • None in v1.3, but future versions may enforce stricter validation (e.g., required secret_key).

Pro Tips

  • Testing: Use RecaptchaService::fake() in PHPUnit:
    public function testRecaptchaValidation()
    {
        RecaptchaService::fake()->shouldVerifySuccessfully();
        // Test logic...
    }
    
  • v3 reCAPTCHA: If using v3, update the service to pass score thresholds:
    $recaptcha->verify($token, 0.9); // Minimum score
    
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor