Introducing the Windows Azure SDK for PHP

June 7, 2012 update: The Microsoft Windows Azure team has released a new Windows Azure SDK for PHP. This release is part of an effort to keep PHP client libraries up to date with new Windows Azure features and to make PHP a first-class citizen in Windows Azure. The latest client libraries are on GitHub: While the SDK hosted on CodePlex will continue to work for the foreseeable future, it is strongly recommended that new PHP/Windows Azure application use the SDK hosted on GitHub.

The work done by Maarten Balliauw and other contributors in building the SDK hosted on CodePlex was critical in unifying the PHP developer experience for Windows Azure. The Windows Azure team is grateful to these contributors for their pioneering work and looks forward to their continued support (and yours!) in adding to the new SDK on GitHub.


The Windows Azure Team

The Windows Azure SDK for PHP isn’t exactly new, so maybe it doesn’t need an introduction. However, for anyone building PHP applications for the Windows Azure platform, this SDK is essential. Besides, if you haven’t checked out the 4.0 release (or you have never heard of it), then an introduction is in order. In this post, I’ll provide links to resources that will help you get started with and use the SDK. As you’ll see by the links below, I’m leaning heavily on the AzurePHP site maintained by the Interoperability Team at Microsoft.

What’s in the SDK, Where to get it, and How to set it up

This post, Set up the Windows Azure SDK for PHP, does a great job of providing an overview of the SDK, showing options for getting it, and showing how to set it up. The diagram below (from that post) shows how the SDK can be divided into three main components:

  • A class library for accessing Windows Azure storage services, logging information in Blob storage, gathering diagnostics information about your services and deployments, and managing your services and deployments. For API reference documentation, point your favorite PHP documentation generator at the \library directory of the SDK.
  • A set of command line tools (package, scaffolder, deployment, certificate, storage, and service) for building, packaging, deploying, and managing projects in Windows Azure. For more detail (including examples), type the tool name and hit enter at the command line after you have set up the SDK.
  • A set of project templates (“scaffolds”) in the form of .phar files. (More on these templates in the How to package and deploy applications section below.)


How to package and deploy applications

The 4.0 release of the Windows Azure SDK for PHP introduced the concept “scaffolds” for packaging PHP applications to Windows Azure. If you have been using the Windows Azure Command Line Tools for PHP Developers for this purpose, getting your head around scaffolds takes a little work. Once you get used to using scaffolds, they are quite simple and quite powerful. A scaffold is a PHP/Azure project template in the form of a .phar file. The SDK ships with a default template (in the /scaffolders directory) that you can use to deploy an application – just add your application’s source code to the PhpOnAzure.Web directory of the project produced by running the scaffolder against the default scaffold. This post, Build and deploy a Windows Azure PHP application, will walk you through all the details.

The power of scaffolds becomes evident in these posts:

From those posts you begin to understand how a scaffold can be created for any application. The scaffolder tool then allows anyone to run it and add their application-specific information (e.g. SQL Azure database connection information) and quickly deploy to Azure. For information about creating a scaffold for your own application, see Using Scaffolds.

How to access Windows Azure Blob, Table, and Queue storage services

Within the class library for the SDK, there are classes for accessing the Windows Azure Blob, Table, and Queue storage services. The main classes you’ll use are the Microsoft_WindowsAzure_Storage_Table, Microsoft_WindowsAzure_Storage_Blog, and Microsoft_WindowsAzure_Storage_Queue classes. Details on how to use these classes can be found in these articles (note that some of these tutorials are based on versions of the SDK prior to the 4.0 release, but storage APIs have maintained backward compatibility):

Using Table Storage
Using Blob Storage
Using the Queue Service

Other resources

For reference, here are other resources worth checking out:

That’s quite a few resources, but I’m sure there are more out there. If you come across good resources related to the Windows Azure SDK for PHP, please let me know and I’ll add them to this post. As I gather more resources, maybe I can put together a sort of “table of contents” of what’s out there. And, of course, if you are looking for a resource that doesn’t exist, let me know…I’ll write it!



Share this on Twitter