stafftastic / laravel-cloudevents
A reusable cloudevent system for laravel projects.
Installs: 13 706
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- cloudevents/sdk-php: ^1.0
- illuminate/support: ^6.0|^7.0|^8.0|^9.0|^10.0
- mateusjunges/laravel-kafka: ^1.8
Requires (Dev)
- psalm/plugin-laravel: ^1.4
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^4.1
README
This repo is no longer maintained. We wholly recommend just using the Laravel Kafka package and CloudEvents library directly.
Laravel CloudEvents
A Laravel library to publish Illuminate Events to Kafka.
Installation
Install the package:
composer require stafftastic/laravel-cloudevents
Usage
- Publish config file
php artisan vendor:publish --provider="stafftastic\LaravelCloudEvents\CloudEventServiceProvider"
- Create your applications context:
<?php namespace App\Events; use App\Models\User; use Illuminate\Broadcasting\InteractsWithSockets; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; use stafftastic\CloudEvents\CloudEventable; use stafftastic\CloudEvents\IsCloudEvent; class UserCreated implements CloudEventable { use Dispatchable; use InteractsWithSockets; use SerializesModels; use IsCloudEvent; /** * Create a new event instance. * * @param \Domain\Users\Models\User $user * * @return void */ public function __construct(public User $user) { } public function getCloudEventType(): string { return 'com.stafftastic.users.created'; } public function getCloudEventTopic(): string { return 'stafftastic'; } public function toCloudEventData(): array { return [ 'user' => $this->user, ]; } }