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

Laravel Webhook Client Laravel Package

spatie/laravel-webhook-client

Receive and process incoming webhooks in Laravel. Verify signatures, store webhook payloads, and handle them in queued jobs. Flexible configuration for multiple webhook endpoints and secure validation.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Event-Driven Integration: The package excels in Laravel’s event-driven architecture, enabling seamless integration with webhook-based workflows (e.g., payment gateways, SaaS notifications, or IoT events). It aligns with Laravel’s queue system for asynchronous processing, reducing latency in HTTP responses.
  • Modular Design: The package’s extensibility (custom validators, profiles, responses, and jobs) fits Laravel’s modular ecosystem, allowing TPMs to tailor behavior without monolithic refactoring.
  • Database-Centric: The webhook_calls table provides auditability and replayability, critical for compliance (e.g., GDPR) or debugging. This aligns with Laravel’s Eloquent ORM and database-first approach.

Integration Feasibility

  • Laravel Native: Built for Laravel (v8+), leveraging core features like middleware, queues, and routing. Minimal boilerplate for basic use cases (e.g., Route::webhooks()).
  • Third-Party Compatibility: Supports HMAC-signed payloads (common in Stripe, GitHub, etc.), but requires upfront validation of the sender’s signature format. Custom validators mitigate this risk.
  • Queue Dependency: Requires a queue driver (e.g., Redis, database) for async processing. Sync queues are discouraged, which may necessitate infrastructure changes.

Technical Risk

  • Signature Validation Complexity: Misconfigured validators (e.g., incorrect HMAC algorithm) could lead to false positives/negatives, requiring rigorous testing with sender-specific payloads.
  • Job Failures: If the ProcessWebhookJob throws uncaught exceptions, the package logs them to the WebhookCall model but doesn’t retry by default. TPMs must implement retry logic (e.g., Laravel Horizon) or dead-letter queues.
  • Performance: Storing all headers (store_headers: ['*']) could bloat the database. TPMs must balance audit needs with storage costs.
  • Laravel Version Lock: The package targets modern Laravel (v8+). Legacy apps may require polyfills or forks.

Key Questions

  1. Sender-Specific Requirements:
    • Does the webhook sender use a non-HMAC signature (e.g., JWT, API keys)? If so, a custom SignatureValidator is mandatory.
    • Are there rate limits or payload size constraints? The package doesn’t enforce these natively.
  2. Processing Guarantees:
    • Is idempotency required (e.g., duplicate webhooks)? The package lacks built-in deduplication; TPMs must implement this (e.g., via webhook_calls uniqueness constraints).
    • What’s the SLA for processing? Queue backlogs could delay handling; TPMs may need to monitor job queues.
  3. Scaling:
    • How many webhook endpoints will be supported? The package supports multiple configs, but TPMs must validate routing/validation logic scales.
  4. Monitoring:
    • Are there alerts for failed webhooks? The package doesn’t include observability tools; TPMs must integrate with Laravel Scout or third-party APM.
  5. Compliance:
    • Are webhook payloads sensitive? The package stores raw payloads by default; TPMs may need encryption (e.g., Laravel Encryption) or PII redaction.

Integration Approach

Stack Fit

  • Laravel Ecosystem: Perfect fit for Laravel apps using:
    • Queues: Async processing via ProcessWebhookJob.
    • Middleware: Signature validation happens transparently.
    • Eloquent: WebhookCall model integrates with Laravel’s ORM.
    • Routing: Route::webhooks() simplifies endpoint registration.
  • Infrastructure:
    • Queues: Requires Redis, database, or external queue (e.g., RabbitMQ) for async jobs.
    • Database: MySQL/PostgreSQL for webhook_calls table (supports migrations).
    • CSRF: Exempts webhook routes from CSRF protection (configured via middleware).
  • Extensions:
    • Custom Validators: For non-HMAC signatures (e.g., JWT, OAuth).
    • Profiles: Filter webhooks by payload structure (e.g., shouldProcess checks for event.type === 'payment.succeeded').
    • Responses: Custom HTTP responses (e.g., 202 Accepted for async processing).

Migration Path

  1. Assessment Phase:
    • Audit existing webhook handlers (if any) for compatibility gaps.
    • Validate sender signatures and payload structures against the package’s assumptions.
  2. Setup:
    • Install via Composer: composer require spatie/laravel-webhook-client.
    • Publish config/migrations: php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider".
    • Configure .env with WEBHOOK_CLIENT_SECRET and queue driver.
  3. Routing:
    • Replace legacy webhook routes with Route::webhooks('endpoint').
    • Exempt routes from CSRF (via middleware or VerifyCsrfToken).
  4. Job Implementation:
    • Extend ProcessWebhookJob to handle business logic (e.g., trigger Laravel events, update models).
    • Example:
      namespace App\Jobs;
      use Spatie\WebhookClient\Jobs\ProcessWebhookJob;
      class HandleStripeWebhook extends ProcessWebhookJob {
          public function handle() {
              $payload = $this->webhookCall->payload;
              // Process Stripe event (e.g., create invoice, log payment)
          }
      }
      
  5. Testing:
    • Unit test signature validation with mock requests.
    • Integration test the queue job with a test payload.
    • Load test with expected traffic volume (e.g., 1000 webhooks/minute).

Compatibility

  • Laravel Versions: Officially supports v8+. For v7, use v1.x of the package (deprecated).
  • PHP Versions: Requires PHP 8.0+. TPMs must ensure server compatibility.
  • Queue Drivers: Supports all Laravel queue drivers (database, Redis, etc.), but async drivers are recommended.
  • Database: Schema is agnostic (MySQL, PostgreSQL, SQLite), but migrations must run.
  • Third-Party: No hard dependencies beyond Laravel core, but custom validators may require libraries (e.g., firebase/php-jwt for JWT).

Sequencing

  1. Phase 1: Core Integration (2–4 weeks):
    • Implement a single webhook endpoint (e.g., Stripe).
    • Validate signature, store payload, and process via queue.
    • Monitor for failures/exceptions.
  2. Phase 2: Extensions (1–2 weeks):
    • Add custom validators/profiles for other senders (e.g., GitHub, Slack).
    • Implement retry logic for failed jobs (e.g., Laravel Horizon).
  3. Phase 3: Observability (1 week):
    • Add logging/monitoring (e.g., Laravel Telescope for WebhookCall failures).
    • Set up alerts for high failure rates.
  4. Phase 4: Scaling (Ongoing):
    • Optimize queue workers (e.g., batch processing).
    • Archive old webhook_calls (configurable via delete_after_days).

Operational Impact

Maintenance

  • Configuration Drift: Multiple webhook configs (e.g., Stripe, GitHub) increase maintenance complexity. TPMs should:
    • Document each config’s purpose (e.g., name: 'stripe').
    • Use environment variables for secrets (e.g., WEBHOOK_CLIENT_STRIPE_SECRET).
  • Dependency Updates: The package is actively maintained (last release: 2026-06-04). TPMs should:
    • Monitor for breaking changes (e.g., Laravel v9+ compatibility).
    • Test updates in staging before production.
  • Schema Changes: Migrations for webhook_calls are versioned. TPMs should:
    • Backup the table before major updates.
    • Test rollback procedures.

Support

  • Troubleshooting:
    • Signature Failures: Check WEBHOOK_CLIENT_SECRET and sender’s signature format.
    • Queue Failures: Monitor Laravel Horizon or queue worker logs for job exceptions.
    • Payload Issues: Inspect webhook_calls table for malformed data.
  • Community: Limited dependents (0) but active GitHub issues. TPMs may need to:
    • Engage with Spatie’s support (MIT license allows commercial use).
    • Contribute fixes for edge cases (e.g., custom signature schemes).
  • Documentation: Comprehensive README and API docs. TPMs should:
    • Create internal runbooks for common issues (e.g., "Webhook not processed").
    • Document custom validators/profiles for onboarding.

Scaling

  • Horizontal Scaling:
    • Stateless processing: Queue workers can scale horizontally (e.g., Kubernetes pods).
    • Database: webhook_calls table may need indexing (e.g., created_at, payload_hash) for large volumes.
  • Vertical Scaling:
    • Queue backpressure: Monitor queue length (e.g.,
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony