PHPackages                             cwssrl/azure-storage-php - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. cwssrl/azure-storage-php

Abandoned → [azure-oss/storage](/?search=azure-oss%2Fstorage)ArchivedLibrary[File &amp; Storage](/categories/file-storage)

cwssrl/azure-storage-php
========================

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure storage APIs.

v1.6.0(2y ago)02.8k↓23.8%11MITPHPPHP ^8.0.0

Since Jan 22Pushed 2y agoCompare

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

READMEChangelogDependencies (6)Versions (2)Used By (1)

Azure-OSS Storage PHP Client Libraries
======================================

[](#azure-oss-storage-php-client-libraries)

This project was forked due the retirement of the official Azure SDK. For more information visit [Retirement notice: The Azure Storage PHP client libraries will be retired on 17 March 2024](https://aka.ms/AzStoragePHPSDKRetirement).

---

Features
--------

[](#features)

- Blobs
    - create, list, and delete containers, work with container metadata and permissions, list blobs in container
    - create block and page blobs (from a stream or a string), work with blob blocks and pages, delete blobs
    - work with blob properties, metadata, leases, snapshot a blob
- Tables
    - create and delete tables
    - create, query, insert, update, merge, and delete entities
    - batch operations
- Queues
    - create, list, and delete queues, and work with queue metadata and properties
    - create, get, peek, update, delete messages
- Files
    - create, list, and delete file shares and directories
    - create, delete and download files

Please check details on [API reference documents](http://azure.github.io/azure-storage-php).

Minimum Requirements
--------------------

[](#minimum-requirements)

- PHP 8.0 or above
- Required extension for PHP:
    - fileinfo
    - mbstring
    - openssl
    - xsl
    - curl

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

[](#install-via-composer)

```
composer require azure-oss/storage
```

Usage
-----

[](#usage)

There are four basic steps that have to be performed before you can make a call to any Microsoft Azure Storage 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 rest proxy classes, such as **BlobRestProxy** class:

```
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
```

To process exceptions you need:

```
use MicrosoftAzure\Storage\Common\ServiceException;
```

- To instantiate the service client you will also need a valid [connection string](https://azure.microsoft.com/en-us/documentation/articles/storage-configure-connection-string/). The format is:

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

Or:

```
BlobEndpoint=myBlobEndpoint;QueueEndpoint=myQueueEndpoint;TableEndpoint=myTableEndpoint;FileEndpoint=myFileEndpoint;SharedAccessSignature=sasToken
```

Or if AAD authentication is used:

```
BlobEndpoint=myBlobEndpoint;QueueEndpoint=myQueueEndpoint;TableEndpoint=myTableEndpoint;FileEndpoint=myFileEndpoint;AccountName=[yourAccount]
```

Note that account name is required.

- Instantiate a client object - a wrapper around the available calls for the given service.

```
$blobClient = BlobRestProxy::createBlobService($connectionString);
$tableClient = TableRestProxy::createTableService($connectionString);
$queueClient = QueueRestProxy::createQueueService($connectionString);
$fileClient = FileRestProxy::createFileService($connectionString);
```

Or for AAD authentication:

```
$blobClient = BlobRestProxy::createBlobServiceWithTokenCredential($token, $connectionString);
$queueClient = QueueRestProxy::createQueueServiceWithTokenCredential($token, $connectionString);
```

Note that Blob and Queue service supports AAD authentication.

### Using Middlewares

[](#using-middlewares)

To specify the middlewares, user have to create an array with middlewares and put it in the `$requestOptions` with key 'middlewares'. The sequence of the array will affect the sequence in which the middleware is invoked. The `$requestOptions` can usually be set in the options of an API call, such as `MicrosoftAzure\Storage\Blob\Models\ListBlobOptions`.

The user can push the middleware into the array with key 'middlewares' in services' `$_options` instead when creating them if the middleware is to be applied to each of the API call for a rest proxy. These middlewares will always be invoked after the middlewares in the `$requestOptions`. e.g.:

```
$tableClient = TableRestProxy::createTableService(
    $connectionString,
    $optionsWithMiddlewares
);
```

Each of the middleware should be either an instance of a sub-class that implements `MicrosoftAzure\Storage\Common\Internal\IMiddleware`, or a `callable` that follows the Guzzle middleware implementation convention.

User can create self-defined middleware that inherits from `MicrosoftAzure\Storage\Common\Internal\Middlewares\MiddlewareBase`.

Retrying failures
-----------------

[](#retrying-failures)

You can use bundled middlewares to retry requests in case they fail for some reason. First you create the middleware:

```
$retryMiddleware = RetryMiddlewareFactory::create(
    RetryMiddlewareFactory::GENERAL_RETRY_TYPE,  // Specifies the retry logic
    3,  // Number of retries
    1000,  // Interval
    RetryMiddlewareFactory::EXPONENTIAL_INTERVAL_ACCUMULATION,  // How to increase the wait interval
    true  // Whether to retry connection failures too, default false
);
```

Then you add the middleware when creating the service as explained above:

```
$optionsWithMiddlewares = [
    'middlewares' = [
        $retryMiddleware
    ],
];
$tableClient = TableRestProxy::createTableService(
    $connectionString,
    $optionsWithMiddlewares
);
```

Or by pushing it to the existing service:

```
$tableClient->pushMiddleware($retryMiddleware);
```

Following errors are not retried in current retry middleware:

- Authentication failures.
- "Resource Not Found" errors.
- Guzzle request exceptions that does not bear an HTTP response, e.g. failed to open stream, or cURL Connection reset by peer, etc. *Note:* Community contribution to cover the Guzzle request exceptions are welcomed.

### Retry types

[](#retry-types)

- `RetryMiddlewareFactory::GENERAL_RETRY_TYPE` - General type of logic that handles retry
- `RetryMiddlewareFactory::APPEND_BLOB_RETRY_TYPE` \* For the append blob retry only, currently the same as the general type

### Interval accumulations

[](#interval-accumulations)

- `RetryMiddlewareFactory::LINEAR_INTERVAL_ACCUMULATION` - The interval will be increased linearly, the *nth* retry will have a wait time equal to *n \* interval*
- `RetryMiddlewareFactory::EXPONENTIAL_INTERVAL_ACCUMULATION` - The interval will be increased exponentially, the *nth* retry will have a wait time equal to *pow(2, n) \* interval*

### Using proxies

[](#using-proxies)

To use proxies during HTTP requests, set system variable `HTTP_PROXY` and the proxy will be used.

Troubleshooting
---------------

[](#troubleshooting)

### Error: Unable to get local issuer certificate

[](#error-unable-to-get-local-issuer-certificate)

cURL can't verify the validity of Microsoft certificate when trying to issue a request call to Azure Storage Services. You must configure cURL to use a certificate when issuing https requests by the following steps:

1. Download the cacert.pem file from [cURL site](http://curl.haxx.se/docs/caextract.html).
2. Then either:

    - Open your php.ini file and add the following line:

        ```
        curl.cainfo = ""
        ```

        OR
    - Point to the cacert in the options when creating the Relevant Proxy.

        ```
        //example of creating the FileRestProxy
        $options["http"] = ["verify" => ""];
        FileRestProxy::createFileService($connectionString, $options);
        ```

Code samples
------------

[](#code-samples)

You can find samples in the [samples folder](https://github.com/Azure-OSS/azure-storage-php/tree/main/samples).

Contribute Code or Provide Feedback
-----------------------------------

[](#contribute-code-or-provide-feedback)

You can find more details for contributing in the [CONTRIBUTING.md](CONTRIBUTING.md).

If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure-OSS/azure-storage-php/issues) section of the project.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor3

3 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

839d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0f054791dd25f449ec129231dec3beb191c471e87bb5f8d5df14390ca4ca74a2?d=identicon)[cwssrl](/maintainers/cwssrl)

---

Top Contributors

[![katmsft](https://avatars.githubusercontent.com/u/21050104?v=4)](https://github.com/katmsft "katmsft (105 commits)")[![pimjansen](https://avatars.githubusercontent.com/u/1457219?v=4)](https://github.com/pimjansen "pimjansen (43 commits)")[![XiaoningLiu](https://avatars.githubusercontent.com/u/6889160?v=4)](https://github.com/XiaoningLiu "XiaoningLiu (32 commits)")[![vinjiang](https://avatars.githubusercontent.com/u/6924113?v=4)](https://github.com/vinjiang "vinjiang (32 commits)")[![spaze](https://avatars.githubusercontent.com/u/1966648?v=4)](https://github.com/spaze "spaze (30 commits)")[![hason-msft](https://avatars.githubusercontent.com/u/129233486?v=4)](https://github.com/hason-msft "hason-msft (24 commits)")[![jeffreylasut](https://avatars.githubusercontent.com/u/412658?v=4)](https://github.com/jeffreylasut "jeffreylasut (10 commits)")[![sergey-shandar](https://avatars.githubusercontent.com/u/902339?v=4)](https://github.com/sergey-shandar "sergey-shandar (8 commits)")[![nowenL](https://avatars.githubusercontent.com/u/6396597?v=4)](https://github.com/nowenL "nowenL (6 commits)")[![z38](https://avatars.githubusercontent.com/u/3948085?v=4)](https://github.com/z38 "z38 (4 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (3 commits)")[![jondmcelroy](https://avatars.githubusercontent.com/u/4562548?v=4)](https://github.com/jondmcelroy "jondmcelroy (3 commits)")[![luxifer](https://avatars.githubusercontent.com/u/419078?v=4)](https://github.com/luxifer "luxifer (3 commits)")[![ganboonhong](https://avatars.githubusercontent.com/u/10766871?v=4)](https://github.com/ganboonhong "ganboonhong (2 commits)")[![manumsft](https://avatars.githubusercontent.com/u/82905109?v=4)](https://github.com/manumsft "manumsft (2 commits)")[![jezmck](https://avatars.githubusercontent.com/u/89996?v=4)](https://github.com/jezmck "jezmck (2 commits)")[![dluces](https://avatars.githubusercontent.com/u/262662?v=4)](https://github.com/dluces "dluces (2 commits)")[![microsoft-github-policy-service[bot]](https://avatars.githubusercontent.com/in/95686?v=4)](https://github.com/microsoft-github-policy-service[bot] "microsoft-github-policy-service[bot] (2 commits)")[![chack1172](https://avatars.githubusercontent.com/u/12584098?v=4)](https://github.com/chack1172 "chack1172 (2 commits)")[![seanmcc-msft](https://avatars.githubusercontent.com/u/44180881?v=4)](https://github.com/seanmcc-msft "seanmcc-msft (1 commits)")

---

Tags

phpsdkstorageazure

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cwssrl-azure-storage-php/health.svg)

```
[![Health](https://phpackages.com/badges/cwssrl-azure-storage-php/health.svg)](https://phpackages.com/packages/cwssrl-azure-storage-php)
```

###  Alternatives

[microsoft/azure-storage-common

This project provides a set of common code shared by Azure Storage Blob, Table, Queue and File PHP client libraries.

4316.8M6](/packages/microsoft-azure-storage-common)[azure-oss/storage

Azure Blob Storage PHP SDK

37985.0k5](/packages/azure-oss-storage)[microsoft/azure-storage-blob

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Blob APIs.

5516.0M57](/packages/microsoft-azure-storage-blob)[microsoft/azure-storage-file

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage File APIs.

152.4M8](/packages/microsoft-azure-storage-file)[rsd/seafile-php-sdk

This is a PHP package for accessing Seafile Web API

3589.1k](/packages/rsd-seafile-php-sdk)[microsoft/azure-storage-queue

This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage Queue APIs.

142.6M16](/packages/microsoft-azure-storage-queue)

PHPackages © 2026

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