A New Windows Azure SDK for PHP
Join the DZone community and get the full member experience.Join For Free
The spring update to Windows Azure contained lots of updates that are relevant to developers using Open Source technologies (and PHP developers in particular) – not the least of which is the release of a “new” Windows Azure SDK for PHP. In this post, I’ll look at the “why”, the “what”, and the “what’s next” for the new SDK.
Why a “new” SDK?
If you’ve looked at any of the posts I’ve written that show how to use the “old” SDK in some way, you’ve probably seen this amendment to those posts:
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: https://github.com/WindowsAzure/azure-sdk-for-php. 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 team does want to make PHP a first-class citizen on Windows Azure. I think the work done to support PHP in Windows Azure Websites is just one bit of evidence that the team is serious about this. The fact that the team has committed resources to building and maintaining a new Windows Azure SDK for PHP is more evidence. But why a “new” SDK? As you may have gleaned from the spring update, the Windows Azure team is working hard to unify the developer experience for Windows Azure. Building an SDK that parallels SDKs for other languages is part of that work. Practically, this will make it easier a developer to use multiple languages with Windows Azure. Additionally, the Windows Azure team is moving fast and they wanted a way to make sure that all client libraries (including PHP) could be kept up-to-date with their fast paced changes. With the many new changes being released in the spring update, starting work on a new SDK seemed like the best way to go. This gave the Windows Azure team the opportunity to standardize client libraries on the new REST API (part of the effort to unify the developer experience).
As the note above mentions, the Windows Azure team owes a debt of gratitude to Maarten Balliauw (and other contributors) for the pioneering work he did in beginning this work. I also owe Maarten my thanks. It was through the SDK that he started that I learned a great deal about building applications for Windows Azure. Of course, our hope is that Maarten and others will continue their work by contributing to the new SDK on GitHub.
What’s in the new SDK?
The new Windows Azure SDK for PHP consists of several components:
- The PHP client libraries for Windows Azure
- The Windows Azure Command-Line Tools for Mac and Linux
- Windows Azure PowerShell (Windows Only)
- The Windows Azure Emulators (Windows Only)
I’ll describe these in more detail below, but if you’d rather just get started, see How to download the Windows Azure SDK for PHP.
The PHP client libraries for Windows Azure
The PHP client libraries for Windows Azure are are hosted on GitHub and provide an interface for accessing Windows Azure features, such as Cloud Storage and Cloud Services. Because most of these classes wrap the Windows Azure REST API, they can be used from any application on any platform that supports PHP. Currently, the client libraries support the following Windows Azure features:
- Windows Azure Storage Services (Blobs, Tables, and Queues). You can learn how to uses the classes for leveraging the Blob, Tables, and Queue services in these articles:
- Service Runtime. The ServiceRuntime class represents the Windows Azure environment in which a role instance is running. The class provides information about the configuration, endpoints, and status of running role instances, and well as functionality for configuring endpoints. (Look for a post on how to use this class soon.)
- Service Management. These classes allow you to programmatically manage Windows Azure services (e.g. create or delete a storage account). (Again, look for a post soon on how to uses these classes.)
The classes that support Service Runtime and Service Management are for PHP applications that will be run as Windows Azure Cloud Services (i.e. as Platform-as-a-Service (PaaS) applications). The classes that support Windows Azure Storage Services, however, are intended for use from any PHP application, regardless of where it is running.
You can install the PHP client libraries for Windows Azure as a PEAR package (assuming you have PEAR installed):
pear channel-discover pear.windowsazure.com pear install pear.windowsazure.com/WindowsAzure-0.1.0
Or, you can install the libraries manually by downloading the .zip archive from GitHub (details here). However, the libraries do have dependencies on a few PEAR packages…so it’s really easiest to install PEAR and then install the libraries as a PEAR package (so the dependencies will be managed for you).
For API reference documentation, see the Windows Azure SDK for PHP Documentation.
The Windows Azure Command-Line Tools for Mac and Linux
The Windows Azure Command-Line Tools for Mac and Linux are a set of command-line tools for deploying and managing Windows Azure services, such as Windows Azure Websites and Windows Azure Virtual Machines. These tools work on any platform, including Mac, Linux, and Windows. Note that at this point in time, these tools to not include commands for managing Web and Worker roles.
You can learn how to use these tools here: How to use the Windows Azure Command-Line Tools for Mac and Linux.
Windows Azure PowerShell (Windows only)
Windows Azure PowerShell is a set of PowerShell cmdlets for deploying and managing Windows Azure Services, such as Cloud Services and Virtual Machines. One nice addition to these tools is the Add-AzurePHPWebRole cmdlet. This creates a ready-to-deploy web role that is configured for PHP applications. All you need to do is add your application code. (Look for a more detailed post soon.) Note that at this time, these cmdlets do not provide functionality for for managing Windows Azure Websites.
To learn more, see How to use Windows Azure PowerShell.
The Windows Azure Emulators (Windows only)
The compute and storage emulators are local emulators of Cloud Services and Cloud Storage that allow you to test an application locally. The Windows Azure Emulators run on Windows only. For more information, see Running a Windows Azure Application in the Compute Emulator and Running a Windows Azure Application with the Storage Emulator. (Look for a post soon about how to use the emulators with the new SDK.)
What’s next for the SDK?
The Windows Azure SDK for PHP is still in the beta phase, so there will be lots of improvements in the near future. Some of what you can expect too see are the following:
- Client Libraries:
- Support for more Windows Azure features (e.g. Service Bus).
- Support for installation using Composer.
- Command-Line Tools for Mac and Linux
- Support for Web/Worker roles.
- Windows Azure PowerShell
- Support for PHP Worker Roles
- Support for Windows Azure Websites
To see a detailed list of what the team is actually tracking, see their backlog on GitHub. Of course, if you have suggestions, we’d love to hear them. Or, you can go to GitHub and make suggestions (or fork a project and provide your own patch!).
That’s it for now. As I mentioned in the post, look for deeper dives into some of these areas in the near future.
Published at DZone with permission of Brian Swan, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.