PHP code example of goodway / laravel-nats

1. Go to this page and download the library: Download goodway/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/ */

    

goodway / laravel-nats example snippets

bash
$ php artisan vendor:publish --provider="Goodway\LaravelNats\NatsQueueProvider"

use Goodway\LaravelNats\NatsMessageJob;

class TestNatsJob extends NatsMessageJob
{
    public function body(): mixed
    {
        return [
            'data' => Str::random(32),
            'group_random' => random_int(1,3),
        ];
    }
}

class TestNatsJob extends NatsMessageJob
{
    public function headers(): array
    {
        return [
            'header1_key' => 'header1_value',
            'header2_key' => 'header2_value',
        ];
    }
    ...
}