lasselehtinen / mockingbird-webhook-client
This package receives Mockingbird webhooks and convert them into strongly typed Laravel events.
Package info
github.com/lasselehtinen/mockingbird-webhook-client
pkg:composer/lasselehtinen/mockingbird-webhook-client
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
- spatie/laravel-webhook-client: ^3.7
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^11.0.0||^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Mockingbird Webhook Client
This package receives Mockingbird webhooks and convert them into strongly typed Laravel events. Applications consume normal Laravel events and do not need to interact with raw webhook requests.
The package is built on top of spatie/laravel-webhook-client and provides:
- Webhook endpoint registration
- Payload parsing
- Event mapping
- Laravel event dispatching
Installation
composer require lasselehtinen/mockingbird-webhook-client
php artisan vendor:publish --tag="webhook-client-migrations"
php artisan migrate
You should schedule the model:prune Artisan command in your application's routes/console.php to clean up older than 30 days old entries from the webhook_calls table.
use Illuminate\Support\Facades\Schedule; use Spatie\WebhookClient\Models\WebhookCall; Schedule::command('model:prune', [ '--model' => [WebhookCall::class], ])->daily();
Workflow
The package processes webhooks using the following flow:
Mockingbird
▼
POST /webhooks/mockingbird
▼
Spatie Webhook Controller
▼
WebhookCall persisted
▼
ProcessMockingbirdWebhookJob
▼
MockingbirdWebhookData DTO
▼
MockingbirdEventFactory
▼
Laravel Event
▼
Application Event Listener
Supported Event Types
Mockingbird event types are mapped to Laravel events.
- AssetUpdated
- EditionUpdated
- ContactUpdated
- EditionContributorsUpdated
- EditionPriceUpdated
- EditionTextsUpdated
- PrintTimePlanUpdated
Webhook Endpoint
The package automatically registers:
POST /webhooks/mockingbird
Incoming requests are validated, stored and processed asynchronously.
Example usage
<?php namespace App\Providers; use App\Listeners\UpdateOnixMessage; use App\Listeners\SyncContributorData; use App\Listeners\UpdateMetadataInExternalAssetManagement; use Lasselehtinen\MockingbirdWebhookClient\Events\AssetUpdated; use Lasselehtinen\MockingbirdWebhookClient\Events\EditionContributorsUpdated; use Lasselehtinen\MockingbirdWebhookClient\Events\EditionUpdated; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider { protected $listen = [ EditionUpdated::class => [ UpdateOnixMessage::class, ], EditionContributorsUpdated::class => [ SyncContributorData::class, ], AssetUpdated::class => [ UpdateMetadataInExternalAssetManagement::class, ], ]; }
Data Transfer Object
Every webhook is converted into a MockingbirdWebhookData DTO.
final readonly class MockingbirdWebhookData { public string $eventType; public string $specVersion; public string $entityId; public string $deliveryId; public CarbonImmutable $occurredAt; public array $payload }
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.