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/ */
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.