New Windows Azure SDK for PHP Feature: RunPHP (on Windows)

If you are developing PHP on Windows for use on Windows Azure, there is a fancy new feature which may catch your attention. First things first, let’s run through the basics of installing the Windows Azure SDK for PHP in order to set up your environment to get ready for PHP development for Windows Azure.

This new feature is part of the Windows Azure PowerShell and Windows Azure Emulators components which is downloadable through the Web Platform Installer.

Install Windows Azure PowerShell and Windows Azure Emulators for PHP

  1. Open Web Platform Installer via the Windows Azure PowerShell and Windows Azure Emulators deep link.
  2. Click Run.

    image

  3. Accept UAC prompt.

    image

  4. Click Install.

    clip_image001

  5. Click I Accept.

    clip_image001[6]

  6. Go to the kitchen and grab a cup of coffee.

    clip_image001[9]

  7. Click Finish.

    image

How To: Use RunPHP to test a PHP Application on Windows

In order to understand how to use runphp, let’s quickly build a sample PHP application to show off the functionality of runphp.

Now that we have a simple application set up, let’s open a command prompt to use runphp. I will use Windows PowerShell to execute commands, in order to use runphp, PowerShell will need to be run as Administrator.

To run PowerShell as Administrator, right click on the PowerShell icon and select Run as Administrator.

Navigate to the path which contains your application, then execute the command runphp.

image

There are a number of things going on when executing RunPHP, let’s enumerate the high level steps:

  1. Copies an apphost.config file to the current directory
  2. Runs appcmd.exe from IIS Express
    1. Creates a new Website based on the current directory
    2. Configures a HTTP Handler to map *.php files to php-cgi.exe interpreter
  3. Starts IIS Express and binds the website to an open port.

To view and test your website, open a browser visit the localhost address with the appropriate port which the website was bound to during the runphp process.

http://localhost:8080

Once you finish testing, you can shut down IIS Express by opening the PowerShell window and pressing the ‘Q’ key.

Now that you’ve finishing testing your application on your local machine, you can deploy to Windows Azure Web Sites.