Download the PHP package aivanov-dev/azure-storage-legacy-php without Composer
On this page you can find all versions of the php package aivanov-dev/azure-storage-legacy-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aivanov-dev/azure-storage-legacy-php
More information about aivanov-dev/azure-storage-legacy-php
Files in aivanov-dev/azure-storage-legacy-php
Package azure-storage-legacy-php
Short Description This project provides a set of PHP client libraries that make it easy to access Microsoft Azure storage APIs.
License MIT
Informations about the package azure-storage-legacy-php
Microsoft Azure Storage PHP Client Libraries
This is a clone from https://github.com/Azure/azure-storage-php modified to support php 5.5.
Microsoft Azure Storage PHP Client Libraries
This project provides a set of PHP client libraries that make it easy to access Microsoft Azure Storage services (blobs, tables, queues and files). For documentation on how to host PHP applications on Microsoft Azure, please see the Microsoft Azure PHP Developer Center.
Note
- If you are looking for the Service Bus, Service Runtime, Service Management or Media Services libraries, please visit https://github.com/Azure/azure-sdk-for-php.
- If you need big file (larger than 2GB) or 64-bit integer support, please install PHP 7 64-bit version.
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.
Getting Started
Minimum Requirements
- PHP 5.6 or above
- See composer.json for dependencies
-
Required extension for PHP:
- php_fileinfo.dll
- php_mbstring.dll
- php_openssl.dll
- php_xsl.dll
- Recommended extension for PHP:
- php_curl.dll
Download Source Code
To get the source code from GitHub, type
Install via Composer
-
Create a file named composer.json in the root of your project and add the following code to it:
-
Download composer.phar in your project root.
- Open a command prompt and execute this in your project root
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:
-
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:
To process exceptions you need:
- To instantiate the service client you will also need a valid connection string. The format is:
Or:
Or if AAD authentication is used:
Note that account name is required.
- Instantiate a client object - a wrapper around the available calls for the given service.
Or for AAD authentication:
Note that Blob and Queue service supports AAD authentication.
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
MicrosoftAzureLegacy\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.:
Each of the middleware should be either an instance of a sub-class that
implements MicrosoftAzureLegacy\Storage\Common\Internal\IMiddleware
, or a
callable
that follows the Guzzle middleware implementation convention.
User can create self-defined middleware that inherits from MicrosoftAzureLegacy\Storage\Common\Internal\Middlewares\MiddlewareBase
.
Retrying failures
You can use bundled middlewares to retry requests in case they fail for some reason. First you create the middleware:
Then you add the middleware when creating the service as explained above:
Or by pushing it to the existing service:
Authentication failures and "not found" errors (HTTP codes 403 & 404) are not retried when using the bundled middleware.
Retry types
RetryMiddlewareFactory::GENERAL_RETRY_TYPE
- General type of logic that handles retryRetryMiddlewareFactory::APPEND_BLOB_RETRY_TYPE
- For the append blob retry only, currently the same as the general type
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
To use proxies during HTTP requests, set system variable HTTP_PROXY
and the proxy will be used.
Troubleshooting
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:
-
Download the cacert.pem file from cURL site.
-
Then either:
-
Open your php.ini file and add the following line:
OR
- Point to the cacert in the options when creating the Relevant Proxy.
-
Code samples
You can find samples in the samples folder.
Migrate from Azure SDK for PHP
If you are using Azure SDK for PHP to access Azure Storage Service, we highly recommend you to migrate to this SDK for faster issue resolution and quicker feature implementation. We are working on supporting the latest service features as well as improvement on existing APIs.
For now, Microsoft Azure Storage PHP client libraries share almost the same interface as the storage blobs, tables, queues and files APIs in Azure SDK for PHP. However, there are some minor breaking changes need to be addressed during your migration. You can find the details in BreakingChanges.md.
Need Help?
Be sure to check out the Microsoft Azure Developer Forums on Stack Overflow and github issues if you have trouble with the provided code.
Contribute Code or Provide Feedback
If you would like to become an active contributor to this project please follow the instructions provided in Azure Projects Contribution Guidelines. You can find more details for contributing in the CONTRIBUTING.md.
If you encounter any bugs with the library please file an issue in the Issues section of the project.