- Install the package using composer:
composer require drlopes/azure-service-bus
- Installl the microsoft/azure-servicebus package using pip:
pip install azure-servicebus
- Open the service-bus.py file and replace the following variables with your Azure Service Bus credentials:
NAMESPACE_CONNECTION_STR = "YOUR_CONNECTION_STRING"
SUBSCRIPTION_NAME = "YOUR_SUBSCRIPTION_NAME"
TOPIC_NAME = "YOUR_TOPIC_NAME"
- Open the src/ServiceBus.php file set the $pythonExecutable:
private static string $pythonExecutable = 'python'; // or 'python3' for example
- Import the ServiceBus class and call the fetch method:
use Drlopes\AzureServiceBus\ServiceBus;
$response = ServiceBus::fetch();
- By default, the response will be an associative array, but passing
associative: false
as a parameter will return a json string.
use Drlopes\AzureServiceBus\ServiceBus;
$response = ServiceBus::fetch(associative: false);