PHP code example of l-queue / l-client

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

    

l-queue / l-client example snippets


$natsClient = \LQueue\Factory::getQueue('nats');
// set username and password when you config the nats
$natsClient->getConnectOption()->setUser('derek')->setPass('T0pS3cr3t')->setPort(4242);
$natsClient->driver();
$sid = $natsClient->subscribe(
    'foo',
    function ($response) {
        $response->reply('Reply: Hello, ' . $response->getBody() . ' ^_^!');
    }
);

$natsClient->request(
    'foo',
    'bar',
    function ($response) {
        echo $response->getBody();
    }
);
$natsClient->close();