How to use the Subversion developer snapshot of the Windows Azure PHP SDK on CodePlex with the PHP Command-line Tools

April 13, 2011

Newer Note: The Interoperability Team at Microsoft has annouced a new version of the Windows Azure SDK for PHP which contains a set of shiny new command line tools and has deprecated the Windows Azure PHP Command-line Tools project. This post is not valid for the SDK see http://azurephp.interoperabilitybridges.com for documentation on the new SDK tools

 

How to use the Subversion developer snapshot of the Windows Azure PHP SDK on CodePlex with the PHP Command-line Tools

NOTE: This tutorial was written based on the Windows Azure Command-line Tools for PHP Developers released March 10th, 2011 on CodePlex and may not work on future/past versions of the tools.

Download the Command-line Tools

Go download the Windows Azure Command-line Tools for PHP Developers from http://azurephptools.codeplex.com/ .

Installation instructions can be found at: http://azurephptools.codeplex.com/wikipage?title=Setup%20Guide

Checkout the developer snapshot of the Windows Azure PHP SDK

The CodePlex project page for the Windows Azure SDK for PHP is located at: http://phpazure.codeplex.com/ . Clicking on the “Source Code” tab will provide you with two options for getting the latest PHP SDK source code; TFS or Subversion. I will be using Subversion. You can access the Subversion repository with your favorite client at:

https://PHPAzure.svn.codeplex.com/svn

If you do not have a client, take a look at the CodePlex source control clients page: http://codeplex.codeplex.com/Wikipage?title=Source%20Control%20Clients

Please be sure you understand that using the bleeding edge Subversion files may break your project. Unless you know your project is entirely stable using the Subversion copy you probably should not deploy this to production.

Create a ZIP archive of the developer snapshot

The PHP SDK is stored in a ZIP archive inside the resources folder of the PHP Command-line Tools. This allows developers to easily test newer versions of the PHP SDK on their projects. We need to build the ZIP archive from the Subversion files we just pulled.

  • Open the folder containing the checked out files
  • Open the “trunk” folder
  • The files we need are in this folder. Highlight all the files and right click on them
  • Point to “Send to”
  • Click “Compressed (zipped) folder” in the sub menu that shows (Win Vista and Win 7)
  • Give the new ZIP archive a clever name, without spaces

Get the ZIP archive into the Command-line Tools folder

Open the folder where you installed the Command-line Tools. You will see a “res” folder. The “res” folder contains additional external resources the Command-line Tools rely on. Open the “res” folder. Inside of the “res” folder you will find a “php” folder, open it. You should see a “runtime” folder (contains the version of PHP that is used for every package) and a “PHPAzure….zip” file (maybe several). Copy the ZIP archive made in the previous section into the “php” folder.

Update the Constants.php file

Now that we have the ZIP archive in place we need to update the Constants.php file. This file contains a reference to the PHP SDK archive. The file this reference is set to is the file the tools will use when packaging your project.

  • Go back to the root folder of the Command-line tools
  • Open the “WACmdLineTools folder
  • Open the “Util” folder
  • Open the “Constants.php” file for editing.
  • Find the line containing the constant “FILE_PHP_AZURE_SDK_ZIP” (around line 126) and update the name of the file to reflect the name of the ZIP archive you copied into the “php” folder.
  • Save the changes

Package your project

You should now be able to package your project like you would normally, however the newest Windows Azure PHP SDK will be included with your project instead of the previously used version.

Error: No files to extract!

If you are receiving an error which contains a message stating there are no files to extract from the “library/Microsoft” folder you have probably run into a path separator issue. This is easily solved by slightly changing the Zip.php file. Please note that this is just a quick hack. With the next version of the Command-line Tools you probably will not need to do this at all.

  • From the root folder of the Command-line Tools
  • Open the “WACmdLineTools/Util” folder.
  • Open “Zip.php” for editing
  • Find the line containing “if ( strpos($strEntry, $strZipFolder) === false )” (around line 128)
  • Create two empty lines prior to the statement and insert the following two lines
    • $strEntry = str_replace(‘\\’, ‘/’, $strEntry);
    • $strZipFolder = str_replace(‘\\’, ‘/’, $strZipFolder);
    • Save the changes
    • Rerun the tool and it should work!

Learn more about running PHP on Windows Azure at http://azurephp.interopbridges.com

Leave a Reply

Your email address will not be published. Required fields are marked *