2017 © Pedro Peláez
 

library azure-storage-blob

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

image

microsoft/azure-storage-blob

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

  • Thursday, April 26, 2018
  • by azure-dmsh
  • Repository
  • 10 Watchers
  • 5 Stars
  • 32,251 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 95 % Grown

The README.md

Microsoft Azure Storage Blob PHP Client Library (Deprecated)

For more details on the retirement and alternatives to using this project, visit Retirement notice: The Azure Storage PHP client libraries will be retired on 17 March 2024., (*1)

This project provides a PHP client library that makes it easy to access Microsoft Azure Storage blob services. For documentation on how to host PHP applications on Microsoft Azure, please see the Microsoft Azure PHP Developer Center., (*2)

Latest Stable Version, (*3)

Note, (*4)

  • This repository is currently used for releasing only, please go to azure-storage-php for submitting issues or contribution.
  • 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

Please check details on API reference documents., (*5)

Getting Started

Minimum Requirements

  • PHP 5.6 or above
  • See composer.json for dependencies
  • Required extension for PHP:, (*6)

    • php_fileinfo.dll
    • php_mbstring.dll
    • php_openssl.dll
    • php_xsl.dll
  • Recommended extension for PHP:, (*7)

    • php_curl.dll

Download Source Code

To get the source code from GitHub, type, (*8)

git clone https://github.com/Azure/azure-storage-php.git
cd ./azure-storage-php

Install via Composer

  1. Create a file named composer.json in the root of your project and add the following code to it:
{
  "require": {
    "microsoft/azure-storage-blob": "*"
  }
}
  1. Download composer.phar in your project root., (*9)

  2. Open a command prompt and execute this in your project root, (*10)

php composer.phar install

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., (*11)

  • First, include the autoloader script:
require_once "vendor/autoload.php";
  • Include the namespaces you are going to use., (*12)

    To create any Microsoft Azure service client you need to use the rest proxy classes, such as BlobRestProxy class:, (*13)

use MicrosoftAzure\Storage\Blob\BlobRestProxy;

To process exceptions you need:, (*14)

use MicrosoftAzure\Storage\Common\ServiceException;
  • To instantiate the service client you will also need a valid connection string. The format is:
DefaultEndpointsProtocol=[http|https];AccountName=[yourAccount];AccountKey=[yourKey]

or:, (*15)

BlobEndpoint=[myBlobEndpoint];SharedAccessSignature=[sasToken]
  • Instantiate a client object - a wrapper around the available calls for the given service.
$blobClient = BlobRestProxy::createBlobService($connectionString);

Or for token authentication:, (*16)

$blobClient = BlobRestProxy::createBlobServiceWithTokenCredential($token, $connectionString);

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., (*17)

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.:, (*18)

$blobClient = BlobRestProxy::createBlobService(
    $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., (*19)

User can create self-defined middleware that inherits from MicrosoftAzure\Storage\Common\Internal\Middlewares\MiddlewareBase., (*20)

Using proxies

To use proxies during HTTP requests, set system variable HTTP_PROXY and the proxy will be used., (*21)

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:, (*22)

  1. Download the cacert.pem file from cURL site., (*23)

  2. Then either:, (*24)

    • Open your php.ini file and add the following line: ini curl.cainfo = "<absolute path to cacert.pem>" OR
    • Point to the cacert in the options when creating the Proxy. php $options["http"] = ["verify" => "<absolute path to cacert.pem>"]; BlobRestProxy::createBlobService($connectionString, $options);

Code samples

You can find samples in the samples folder, (*25)

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., (*26)

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., (*27)

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., (*28)

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., (*29)

If you encounter any bugs with the library please file an issue in the Issues section of the project., (*30)

The Versions

26/04 2018

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

by Azure Storage PHP Client Library

php sdk storage azure blob

26/04 2018

1.1.0

1.1.0.0

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

  Sources   Download

MIT

The Requires

 

by Azure Storage PHP Client Library

php sdk storage azure blob

11/01 2018

1.0.0

1.0.0.0

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

  Sources   Download

MIT

The Requires

 

by Azure Storage PHP Client Library

php sdk storage azure blob