PHP code example of outhebox / laravel-ibmq

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

    

outhebox / laravel-ibmq example snippets


return [
    'host' => env('IBM_MQ_HOST', 'your-host'),
    'port' => env('IBM_MQ_PORT', 1414),
    'queue_manager' => env('IBM_MQ_QUEUE_MANAGER', 'your-queue-manager'),
    'username' => env('IBM_MQ_USERNAME', null),
    'password' => env('IBM_MQ_PASSWORD', null),

    'queues' => [
        'inbound' => env('IBM_MQ_INBOUND_QUEUE', 'your-inbound-queue'),
        'outbound' => env('IBM_MQ_OUTBOUND_QUEUE', 'your-outbound-queue'),
    ],
];

use Outhebox\LaravelIBMQ\Facades\LaravelIBMQ;
use Outhebox\LaravelIBMQ\Exceptions\IBMQException;

$ibmQueue = new LaravelIBMQ();

try {
    $ibmQueue->sendMessage('Hello, IBM MQ!');
    echo "Message sent successfully!";
} catch (IBMQException $e) {
    echo "Failed to send message: " . $e->getMessage();
}

use Outhebox\LaravelIBMQ\Facades\LaravelIBMQ;
use Outhebox\LaravelIBMQ\Exceptions\IBMQException;

$ibmQueue = new LaravelIBMQ();

try {
    $ibmQueue->listenToMessages(function ($messageBody) {
        echo "Received message: " . $messageBody;
    });
} catch (IBMQException $e) {
    echo "Failed to receive messages: " . $e->getMessage();
}

use Outhebox\LaravelIBMQ\Facades\LaravelIBMQ;

$ibmQueue = new LaravelIBMQ();

$ibmQueue->close();
bash
php artisan vendor:publish --tag="laravel-ibmq-config"