1. Go to this page and download the library: Download seddighi78/laravel-nats 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/ */
seddighi78 / laravel-nats example snippets
namespace App\Listeners;
use Seddighi78\LaravelNats\Events\MessageReceived;
class PrintOnNatsMessageReceivedListener
{
public function handle(MessageReceived $event): void
{
echo $event->message; // you can proccess the messeage here
}
}
use Seddighi78\LaravelNats\Events\MessageReceived;
use App\Listeners\PrintOnNatsMessageReceivedListener;
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
MessageReceived::class => [
PrintOnNatsMessageReceivedListener::class,
]
];
}