spatie/laravel-webhook-server
Send webhooks from Laravel with configurable endpoints, payloads and headers. Supports request signing, queued delivery, retries with backoff, and failure handling. Ideal for notifying external services when events happen in your app.
Install the package via Composer, publish the config file, and configure your queue driver (avoid sync in production). Start dispatching webhooks with minimal code:
use Spatie\WebhookServer\WebhookCall;
WebhookCall::create()
->url('https://api.example.com/webhook')
->payload(['event' => 'order.created', 'order_id' => 123])
->useSecret(config('webhooks.shared_secret'))
->dispatch();
The DispatchingWebhookCallEvent fires on dispatch, and FinalWebhookCallFailedEvent on total failure—hook into these for monitoring.
OrderShipped, UserRegistered) using listeners or event subscribers.WebhookSender) for consistent payloads, signing, and error handling.WEBHOOK_BASE_URL) via config caching or runtime config (config()->set()).ExponentialBackoffStrategy for external system constraints—e.g., stricter limits for third-party APIs.webhooks) with Horizon workers to isolate retries and prevent blocking critical jobs.Http::fake() in tests; assert dispatched events and payloads.Signature + Timestamp headers; use useTimestamp() to mitigate replay attacks.Timestamp, ensure server clocks are NTP-synchronized.timeout_in_seconds applies per attempt—aggregate retries may exceed business SLAs. Adjust tries and timeout_in_seconds together.verify_ssl => false); never in production. Provide custom CA via verifySsl($caPath) if needed.calculateSignature payload must match what the receiver expects—e.g., JSON key order matters if non-normalized. Test signature generation against actual receivers.throw_exception_on_failure => true in tests to catch failures early, but keep it false in prod to avoid cascading failures.tags config to tag jobs (e.g., ['webhook', 'order_service']), then filter in Horizon for troubleshooting.signature_header_name (Signature) and timestamp_header_name (Timestamp). Mismatches cause validation failures.How can I help you explore Laravel packages today?