1. Go to this page and download the library: Download nuwber/rabbitevents library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Google\Protobuf\StringValue;
+$message = new StringValue();
+$message->setValue('Hello World');
+
+publish('my.event', $message);
public function handle(array $payload) {
// $payload['key']
}
public function handle(\Google\Protobuf\Internal\Message $message) {
// $message->getSomething()
}
use RabbitEvents\Foundation\Contracts\Serializer;
use RabbitEvents\Foundation\Contracts\ContentType;
use RabbitEvents\Foundation\Contracts\Payload;
class MySerializer implements Serializer
{
public function serialize($data): Payload { ... }
public function deserialize($message): Payload { ... }
public function contentType(): ContentType { return new MyContentType(); }
public function canSerialize($payload): bool { ... }
}
namespace App\BroadcastEvents;
use RabbitEvents\Publisher\ShouldPublish;
use RabbitEvents\Publisher\Support\Publishable;
use RabbitEvents\Publisher\Support\PublishableEventTesting;
class Event implements ShouldPublish
{
use Publishable;
use PublishableEventTesting;
public function __construct(private array $payload)
{
}
public function publishEventKey(): string
{
return 'something.happened';
}
public function toPublish(): array
{
return $this->payload;
}
}
use \App\RabbitEvents\Event;
use \App\RabbitEvents\AnotherEvent;
Event::fake();
$payload = [
'key1' => 'value1',
'key2' => 'value2',
];
Event::publish($payload);
Event::assertPublished('something.happened', $payload);
AnotherEvent::assertNotPublished();
bash
php artisan rabbitevents:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.