1. Go to this page and download the library: Download hollyphat/event-bus 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/ */
hollyphat / event-bus example snippets
namespace App\Providers;
use App\Events\HandlePayrollDisbursementBatch;
use Hollyphat\EventBus\ListenerServiceProvider;
class EventListenerServiceProvider extends ListenerServiceProvider
{
protected array $listen = [
// 'payroll.disbursement.batch' => [
// HandlePayrollDisbursementBatch::class,
// ],
];
}
public function handle(Envelope $event): void
{
ProcessPayrollDisbursementBatch::dispatch($event->payload);
}
use Hollyphat\EventBus\Facades\EventBus;
// Way 1 — every backend sees it; each picks via $listen
EventBus::broadcast('organization.user.synced', $payload);
// Way 2 — only the app-b consumer handles it
EventBus::send('app-b', 'payroll.disbursement.batch', $payload);
// Command that needs a reply
$result = EventBus::sendAndWait('app-c', 'seat.member.provision.requested', $payload, timeout: 45);
// Inside the app-c handler
EventBus::reply($event->correlationId, [
'organization_user_id' => 12,
'account_user_id' => 34,
]);
bash
php artisan events:consume
php artisan events:consume
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.