outhebox / laravel-ibmq
This is my package laravel-ibmq
Fund package maintenance!
MohmmedAshraf
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- php-amqplib/php-amqplib: ^3.7
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- spatie/laravel-ray: ^1.35
README
Features | Requirements | Installation | Usage | Changelog
A Laravel package to connect with IBM MQ, allowing for sending and receiving messages. This package supports multiple queues for inbound and outbound messages, with advanced error handling and logging.
Features
- Easy-to-use API for interacting with IBM MQ.
- Separate queues for inbound and outbound messaging.
- Fluent API for sending and receiving messages.
- Configurable via environment variables.
Requirements
- PHP 8.1+ with
ext-sockets
extension enabled - Laravel 10 or higher
- IBM MQ instance
Installation
You can install the package via composer:
composer require outhebox/laravel-ibmq
You can publish the config file with:
php artisan vendor:publish --tag="laravel-ibmq-config"
This is the contents of the published config file:
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'), ], ];
Usage
Sending Messages
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(); }
Listening to Messages
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(); }
Closing Connections
Connections are automatically closed when the object is destroyed or the application ends. However, you can explicitly close the connection if needed:
use Outhebox\LaravelIBMQ\Facades\LaravelIBMQ; $ibmQueue = new LaravelIBMQ(); $ibmQueue->close();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.