PHPackages                             origoenergia/azure-sdk-php-fork-servicebus - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. origoenergia/azure-sdk-php-fork-servicebus

ActiveLibrary[HTTP &amp; Networking](/categories/http)

origoenergia/azure-sdk-php-fork-servicebus
==========================================

This is a fork of the PHP Azure SDK for the service bus

058.1k—3.7%5[1 issues](https://github.com/origoenergia/azure-sdk-php-fork-servicebus/issues)PHP

Since Apr 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/origoenergia/azure-sdk-php-fork-servicebus)[ Packagist](https://packagist.org/packages/origoenergia/azure-sdk-php-fork-servicebus)[ RSS](/packages/origoenergia-azure-sdk-php-fork-servicebus/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Azure Service Bus SDK for PHP
=============================

[](#azure-service-bus-sdk-for-php)

This is a fork of now abandoned Azure SDK for PHP which only focuses on bringing Service Bus to PHP. This fork does not have support for Tables, Blobs, Media Services, Management.

All unit tests were run after the code cleanup and few still fail. This is pretty much work in progress - please help us in testing this library/SDK.

Features
========

[](#features)

- Service Bus
    - Queues: create, list and delete queues; send, receive, unlock and delete messages
    - Topics: create, list, and delete topics; create, list, and delete subscriptions; send, receive, unlock and delete messages; create, list, and delete rules

Getting Started
===============

[](#getting-started)

> **Note**
>
> The recommended way to resolve dependencies is to install them using the [Composer package manager](http://getcomposer.org).

Usage
=====

[](#usage)

Getting Started
---------------

[](#getting-started-1)

There are four basic steps that have to be performed before you can make a call to any Microsoft Azure API when using the libraries.

- First, include the autoloader script:

    ```
    require_once "vendor/autoload.php";
    ```
- Include the namespaces you are going to use.

    To create any Microsoft Azure service client you need to use the **ServicesBuilder** class:

    ```
    use AzureServiceBus\Common\ServicesBuilder;
    ```

    To process exceptions you need:

    ```
    use AzureServiceBus\Common\ServiceException;
    ```
- To instantiate the service client you will also need a valid connection string. The format is:

    - For accessing a live storage service (tables, blobs, queues):

        ```
        DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey]

        ```
    - For accessing the emulator storage:

        ```
        UseDevelopmentStorage=true

        ```
    - For accessing the Service Bus:

        ```
        Endpoint=[yourEndpoint];SharedSecretIssuer=[yourWrapAuthenticationName];SharedSecretValue=[yourWrapPassword]

        ```

        Where the Endpoint is typically of the format `https://[yourNamespace].servicebus.windows.net`.
    - For accessing Service Management APIs:

        ```
        SubscriptionID=[yourSubscriptionId];CertificatePath=[filePathToYourCertificate]

        ```
- Instantiate a "REST Proxy" - a wrapper around the available calls for the given service.

    - For Service Bus:

        ```
        $serviceBusRestProxy = ServicesBuilder::getInstance()->createServiceBusService($connectionString);
        ```

Service Bus Queues
------------------

[](#service-bus-queues)

The current PHP Service Bus APIs only support ACS connection strings. You need to use PowerShell to create a new ACS Service Bus namespace at the present time. First, make sure you have Azure PowerShell installed, then in a PowerShell command prompt, run

```
Add-AzureAccount # this will sign you in
New-AzureSBNamespace -CreateACSNamespace $true -Name 'mytestbusname' -Location 'West US' -NamespaceType 'Messaging'
```

If it is sucessful, you will get the connection string in the PowerShell output. If you get connection errors with it and the conection string looks like Endpoint=sb://..., change it to **Endpoint=https://...**

### Create a Queue

[](#create-a-queue)

```
try {
  $queueInfo = new QueueInfo("myqueue");

  // Create queue.
  $serviceBusRestProxy->createQueue($queueInfo);
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

[Error Codes and Messages](http://msdn.microsoft.com/en-us/library/windowsazure/dd179357)

### Send a Message

[](#send-a-message)

To send a message to a Service Bus queue, your application will call the **ServiceBusRestProxy-&gt;sendQueueMessage** method. Messages sent to (and received from ) Service Bus queues are instances of the **BrokeredMessage** class.

```
try {
  // Create message.
  $message = new BrokeredMessage();
  $message->setBody("my message");

  // Send message.
  $serviceBusRestProxy->sendQueueMessage("myqueue", $message);
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

### Receive a Message

[](#receive-a-message)

The primary way to receive messages from a queue is to use a **ServiceBusRestProxy-&gt;receiveQueueMessage** method. Messages can be received in two different modes: **ReceiveAndDelete** (mark message as consumed on read) and **PeekLock** (locks message for a period of time, but does not delete).

The example below demonstrates how a message can be received and processed using **PeekLock** mode (not the default mode).

```
try {
  // Set the receive mode to PeekLock (default is ReceiveAndDelete).
  $options = new ReceiveMessageOptions();
  $options->setPeekLock(true);

  // Receive message.
  $message = $serviceBusRestProxy->receiveQueueMessage("myqueue", $options);
  echo "Body: ".$message->getBody()."";
  echo "MessageID: ".$message->getMessageId()."";

  // *** Process message here ***

  // Delete message.
  $serviceBusRestProxy->deleteMessage($message);
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

Service Bus Topics
------------------

[](#service-bus-topics)

### Create a Topic

[](#create-a-topic)

```
try {
  // Create topic.
  $topicInfo = new TopicInfo("mytopic");
  $serviceBusRestProxy->createTopic($topicInfo);
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

### Create a subscription with the default (MatchAll) filter

[](#create-a-subscription-with-the-default-matchall-filter)

```
try {
  // Create subscription.
  $subscriptionInfo = new SubscriptionInfo("mysubscription");
  $serviceBusRestProxy->createSubscription("mytopic", $subscriptionInfo);
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

### Send a message to a topic

[](#send-a-message-to-a-topic)

Messages sent to Service Bus topics are instances of the **BrokeredMessage** class.

```
try {
  // Create message.
  $message = new BrokeredMessage();
  $message->setBody("my message");

  // Send message.
  $serviceBusRestProxy->sendTopicMessage("mytopic", $message);
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

### Receive a message from a topic

[](#receive-a-message-from-a-topic)

The primary way to receive messages from a subscription is to use a **ServiceBusRestProxy-&gt;receiveSubscriptionMessage** method. Received messages can work in two different modes: **ReceiveAndDelete** (the default) and **PeekLock** similarly to Service Bus Queues.

The example below demonstrates how a message can be received and processed using **ReceiveAndDelete** mode (the default mode).

```
try {
  // Set receive mode to PeekLock (default is ReceiveAndDelete)
  $options = new ReceiveMessageOptions();
  $options->setReceiveAndDelete();

  // Get message.
  $message = $serviceBusRestProxy->receiveSubscriptionMessage("mytopic",
                                "mysubscription",
                                $options);
  echo "Body: ".$message->getBody()."";
  echo "MessageID: ".$message->getMessageId()."";
} catch(ServiceException $e){
  $code = $e->getCode();
  $error_message = $e->getMessage();
  echo $code.": ".$error_message."";
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7bb2e169ffdc5bc0f20b24de4dd3a4f0f4dcc71dc635d78d6834a8e7c6612779?d=identicon)[OrigoEnergia](/maintainers/OrigoEnergia)

---

Top Contributors

[![origoenergia](https://avatars.githubusercontent.com/u/80329537?v=4)](https://github.com/origoenergia "origoenergia (3 commits)")

### Embed Badge

![Health badge](/badges/origoenergia-azure-sdk-php-fork-servicebus/health.svg)

```
[![Health](https://phpackages.com/badges/origoenergia-azure-sdk-php-fork-servicebus/health.svg)](https://phpackages.com/packages/origoenergia-azure-sdk-php-fork-servicebus)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
