1. Go to this page and download the library: Download jacked-php/live-belt 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\Events;
use Illuminate\Broadcasting\InteractsWithBroadcasting;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
class NotificationReady implements ShouldBroadcastNow
{
use InteractsWithBroadcasting;
public function __construct(
public string $message,
public string $channel,
) {
$this->broadcastVia('conveyor');
}
public function broadcastOn(): array
{
return [
new PrivateChannel($this->channel),
];
}
}
event(new NotificationReady( message: 'Message from Conveyor', channel: 'notifications-{your-user-id-here}')); // remember to replace {your-user-id-here} with your user id
namespace App\Listeners;
use App\Events\NotificationReady;
use LiveBelt\Events\OnConveyorMessage;
class SampleListener
{
public function handle(OnConveyorMessage $event): void
{
logger()->info('Event received from Conveyor Server', [
'event' => $event,
]);
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.