PHPackages                             paulemich/azure-service-bus - 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. paulemich/azure-service-bus

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

paulemich/azure-service-bus
===========================

Framework-agnostic PHP client for the Azure Service Bus REST API (send, peek-lock receive, complete, abandon, schedule, counts) with SAS authentication.

00[1 issues](https://github.com/PaulEmich/azure-service-bus/issues)PHP

Since Jun 3Pushed 1mo agoCompare

[ Source](https://github.com/PaulEmich/azure-service-bus)[ Packagist](https://packagist.org/packages/paulemich/azure-service-bus)[ RSS](/packages/paulemich-azure-service-bus/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Azure Service Bus PHP Client
============================

[](#azure-service-bus-php-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/33303203d244d3cd0875e1650d5d6466ac8a134d33c6590e38ed401be5dbdd19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061756c656d6963682f617a7572652d736572766963652d6275732e737667)](https://packagist.org/packages/paulemich/azure-service-bus)[![Total Downloads](https://camo.githubusercontent.com/d3836a0f10314dcef2d9bd23ae9b83ee0bb2dbc485e72e4ae73b4d92c8f535cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7061756c656d6963682f617a7572652d736572766963652d6275732e737667)](https://packagist.org/packages/paulemich/azure-service-bus)[![License](https://camo.githubusercontent.com/74f2059da2b50b4015af79cd9ffd5ea7d1cc04b9fd3523e7c5650c2ef046f56f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7061756c656d6963682f617a7572652d736572766963652d6275732e737667)](LICENSE.md)

A small, framework-agnostic PHP client for the [Azure Service Bus](https://learn.microsoft.com/azure/service-bus-messaging/) **REST API**. It covers the message operations you need for a worker: sending (including scheduled delivery), peek-lock receive, completing and abandoning locked messages, purging, and reading message counts. Authentication uses Shared Access Signature (SAS) tokens, regenerated per request.

No PHP extensions are required — it speaks HTTP via [Guzzle](https://docs.guzzlephp.org/).

> Looking for a Laravel queue driver built on this client? See [`paulemich/laravel-asb`](https://packagist.org/packages/paulemich/laravel-asb).

Requirements
------------

[](#requirements)

- PHP 8.3+
- An Azure Service Bus namespace and a SAS policy with the appropriate claims (`Send`, `Listen`, and `Manage` for counts).

Installation
------------

[](#installation)

```
composer require paulemich/azure-service-bus
```

Usage
-----

[](#usage)

### Creating a client

[](#creating-a-client)

```
use PaulEmich\AzureServiceBus\ServiceBusClient;

// From a connection string (copy it from the Azure portal):
$client = ServiceBusClient::fromConnectionString(
    'Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=your-key'
);
```

Or wire it up explicitly (handy for injecting your own Guzzle client in tests):

```
use PaulEmich\AzureServiceBus\Auth\SasTokenGenerator;
use PaulEmich\AzureServiceBus\ServiceBusClient;

$client = ServiceBusClient::make(
    'https://my-namespace.servicebus.windows.net',
    new SasTokenGenerator('RootManageSharedAccessKey', 'your-key'),
);
```

### Sending messages

[](#sending-messages)

```
// A plain message
$client->send('orders', json_encode(['id' => 42]));

// Scheduled delivery + a custom TTL, plus a custom application property
$client->send(
    queue: 'orders',
    body: json_encode(['id' => 42]),
    brokerProperties: [
        'MessageId' => 'order-42',
        'ScheduledEnqueueTimeUtc' => gmdate('D, d M Y H:i:s \G\M\T', time() + 600),
        'TimeToLive' => 3600,
    ],
    properties: ['Priority' => 'high'],
);
```

### Receiving, completing and abandoning (peek-lock)

[](#receiving-completing-and-abandoning-peek-lock)

```
$message = $client->receive('orders', waitSeconds: 30);

if ($message !== null) {
    // $message->body, ->messageId(), ->deliveryCount(),
    // ->lockToken(), ->sequenceNumber(), ->property('Priority')

    try {
        handle($message->body);
        $client->complete($message);   // remove it from the queue
    } catch (\Throwable $e) {
        $client->abandon($message);    // unlock -> redelivered, DeliveryCount++
    }
}
```

### Counts and purging

[](#counts-and-purging)

```
$counts = $client->countMessages('orders');
// ['active' => int, 'scheduled' => int, 'deadLetter' => int, 'total' => int]

$removed = $client->purge('orders'); // destructively drains active messages
```

API summary
-----------

[](#api-summary)

MethodDescription`send($queue, $body, $brokerProperties = [], $properties = [])`Send a message; returns the supplied `MessageId` (or `null`)`receive($queue, $waitSeconds = 30)`Peek-lock receive; returns a `ReceivedMessage` or `null``receiveAndDelete($queue, $waitSeconds = 0)`Destructive read`complete($message)`Delete (settle) a locked message`abandon($message)`Unlock a locked message for redelivery`purge($queue)`Drain active messages; returns the count removed`countMessages($queue)`Active / scheduled / dead-letter / total countsErrors from the REST API are wrapped in `PaulEmich\AzureServiceBus\Exceptions\ServiceBusException`.

Testing
-------

[](#testing)

```
composer install
vendor/bin/pest
```

Tests run entirely against a mocked Guzzle handler — no Azure account or network access required.

License
-------

[](#license)

The MIT License (MIT). See [LICENSE.md](LICENSE.md).

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance59

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

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/4c5aba7c688cc3500f3ce2c46de86ed887be5d6a8c6cd3d0c119f090aec4068a?d=identicon)[PaulEmich](/maintainers/PaulEmich)

---

Top Contributors

[![PaulEmich](https://avatars.githubusercontent.com/u/1635879?v=4)](https://github.com/PaulEmich "PaulEmich (1 commits)")

### Embed Badge

![Health badge](/badges/paulemich-azure-service-bus/health.svg)

```
[![Health](https://phpackages.com/badges/paulemich-azure-service-bus/health.svg)](https://phpackages.com/packages/paulemich-azure-service-bus)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25026.1M82](/packages/php-http-cache-plugin)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k122](/packages/httpsoft-http-message)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)[swoft/websocket-server

swoft websocket server component

16135.7k5](/packages/swoft-websocket-server)[thesis/nats

Async (fiber based) client for Nats.

754.4k](/packages/thesis-nats)[jasny/http-signature

Implementation of the IETF HTTP Signatures draft RFC

10104.7k](/packages/jasny-http-signature)

PHPackages © 2026

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