PHPackages                             flaschenpost/azurelib - 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. [API Development](/categories/api)
4. /
5. flaschenpost/azurelib

ActiveLibrary[API Development](/categories/api)

flaschenpost/azurelib
=====================

This project provides a set of PHP client libraries that make it easy to access Windows Azure tables, blobs, queues, service runtime and service management APIs.

v0.0.2(3y ago)0467Apache-2.0PHPPHP &gt;=8.0

Since Sep 28Pushed 3y ago2 watchersCompare

[ Source](https://github.com/fp-pim/azurelib)[ Packagist](https://packagist.org/packages/flaschenpost/azurelib)[ RSS](/packages/flaschenpost-azurelib/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (19)Versions (3)Used By (0)

Flaschenpost Azure Library for PHP
==================================

[](#flaschenpost-azure-library-for-php)

This project provides a set of PHP client libraries that make it easy to access Microsoft™ Azure service bus (queues and topics).

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)

Download Source Code
--------------------

[](#download-source-code)

To get the source code from our repository, type

```
git clone https://FlaschenpostSE@dev.azure.com/FlaschenpostSE/PHP/_git/azurelib
cd ./azurelib

```

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

Install via Composer
--------------------

[](#install-via-composer)

- Create a file named **composer.json** in the root of your project and add the following code to it:

    ```
    {
        "require": {
            "flaschenpost/azurelib": "^0.5"
        }
    }
    ```
- Download **[composer.phar](http://getcomposer.org/composer.phar)** in your project root.
- Open a command prompt and execute this in your project root

    ```
    php composer.phar install

    ```

    > **Note**
    >
    > On Windows, you will also need to add the Git executable to your PATH environment variable.

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 WindowsAzure\Common\ServicesBuilder;
    ```

    To process exceptions you need:

    ```
    use WindowsAzure\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 Service Bus:

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

        ```

        Where the Endpoint is typically of the format `https://[yourNamespace].servicebus.windows.net`.
- 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."";
}
```

Learn More
==========

[](#learn-more)

[Microsoft Azure PHP Developer Center](http://www.windowsazure.com/en-us/develop/php/)

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact  with any additional questions or comments.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~19 days

Total

2

Last Release

1300d ago

PHP version history (2 changes)v0.0.1PHP &gt;=7.0

v0.0.2PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/183aa73d75c2eb3849f89d4ce488157af72eeb5e9a0485d199c62a38187a460b?d=identicon)[dguhl](/maintainers/dguhl)

---

Top Contributors

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

---

Tags

phpsdkazure

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/flaschenpost-azurelib/health.svg)

```
[![Health](https://phpackages.com/badges/flaschenpost-azurelib/health.svg)](https://phpackages.com/packages/flaschenpost-azurelib)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[microsoft/windowsazure

This project provides a set of PHP client libraries that make it easy to access Windows Azure tables, blobs, queues, service runtime and service management APIs.

4241.8M19](/packages/microsoft-windowsazure)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[docusign/esign-client

The Docusign PHP library makes integrating Docusign into your apps and websites a super fast and painless process. The library is open sourced on GitHub, look for the docusign-esign-php-client repository. Join the eSign revolution!

2087.4M13](/packages/docusign-esign-client)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)

PHPackages © 2026

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