Skip to content
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.

stafftastic/laravel-cloudevents

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archival notice

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

  1. Publish config file
php artisan vendor:publish --provider="stafftastic\LaravelCloudEvents\CloudEventServiceProvider"
  1. 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,
        ];
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •