Using the Windows Azure SDK for PHP

Author: Ben Lobaugh <ben@lobaugh.net>

Date: Thursday, December 15, 2011, 11:35:04 AM

Tags: Tutorial, Get Started, Setup, SDK

Table of Contents

Note:This article pertains to the CodePlex SDK initially released late 2009. The Windows Azure team has since then released a newer version of the Azure SDK for PHP on Github. Please refer to the Windows Azure PHP Developer Center for documentation on this more recent version of the SDK.

Please stay tuned and come back here regularly as we are working on refreshing the tutorials to deliver up to date and useful content for our PHP developers.

Pre-requisites

Synopsis

The Windows Azure SDK for PHP is not only used for creating deployment packages, it also contains a full library to access Windows Azure APIs to interact with services such as storage and the Service Management API. This tutorial will show you how to use the Windows Azure SDK for PHP library in your projects.

Where to find the library

After you have installed the Windows Azure SDK for PHP you will also have the library installed on your machine. The library exists in C:\Program Files\Windows Azure SDK for PHP. Depending on the source used to install the SDK the exact location maybe be slightly different, which will be covered later.

Copy the library to your project

The current scaffolding feature of the Windows Azure SDK for PHP will allow you to easily create a new project that contains everything needed to get a PHP application running on Windows Azure, however by default the library is not included in the scaffold. This is a design decision that has been made for the DefaultScaffolder scaffold because it is intended to be as generic and application agnostic as possible. This decision allows you to decide if you need to use the library at all, and even lets you change which version of the library you may want.

Getting the library into your project is as simple as copying the Microsoft folder from the Windows Azure SDK for PHP folder, however where exactly you copy the library from is dependent upon which installation method you chose, archive download or code version repository.

Keep in mind that the Microsoft folder needs to be in every role that you require access to the Windows Azure SDK for PHP from.

Copy from an archive installation

If you installed the Windows Azure SDK for PHP using the archive download the library will be located at:

C:\Program Files\Windows Azure SDK for PHP\library

To copy the files to your application from the terminal use a command similar to below:

xcopy /s /e /h /Y "C:\Program Files\Windows Azure SDK for PHP\library" <YOUR APPLICATION ROLE DIRECTORY>

Copy from a code versioning installation

If you installed the Windows Azure SDK for PHP using Subversion or Team Foundation Server the library will be located at:

C:\Program Files\Windows Azure SDK for PHP\trunk\library

To copy the files to your application from the terminal use a command similar to below:

xcopy /s /e /h /Y "C:\Program Files\Windows Azure SDK for PHP\trunk\library" <YOUR APPLICATION ROLE DIRECTORY>

Include the library in your application

Now that you have the Windows Azure SDK for PHP library in your project folder you still need to include it in your application to take advantage of the functionality. At this point there should be a Microsoft folder in your role folder containing the entire library. In previous versions of the SDK you needed to know the exact path to each object, however in the newer versions an autoloader has been added that allows you to include one file and all the objects are magically available to be instantiated in your project. You will need to add the following line to the application someplace before your code needs access to the SDK objects:

require_once('Microsoft/Autoloader.php');
 
blog comments powered by Disqus

Related Content

No related content was found