PHP 5.4 Now Native in Windows Azure Web Sites

A while back I wrote a blog post on Enabling PHP 5.4 in Windows Azure Web Sites, when we enabled the ability to bring-you-own-runtime to Windows Azure Web Sites. This is still a valid solution if you would like to manage your own PHP.ini file, or if you would like to ensure that you are using a specific build of PHP.

It’s exciting to announce that Windows Azure Web Sites now has PHP 5.4 ready to be enabled in your Web Sites.

Even though PHP 5.4 is available PHP 5.3 is still enabled by default.


Enable Native PHP 5.4 in Windows Azure Web Sites

After Creating a Windows Azure Web Site, navigate into the Web Site details page and select the CONFIGURE tab. Under the framework section you will see PHP VERSION, select the box containing 5.4, it will turn purple notifying that there is an unsaved change.


At the bottom of the browser viewport you will find the TASK DRAWER, which would have changed to include a SAVE button. Click the SAVE button to enable PHP 5.4 for your Windows Azure Web Site.


Once the change has been saved, you’ll be greeted by this nice little success notice.


Finally, you will also notice that the purple indicator has now changed back to blue on the PHP 5.4 box.


You are now ready to deploy PHP 5.4 applications to Windows Azure Web Sites.

Happy Clouding!

Enabling PHP 5.4 in Windows Azure Web Sites

Much like many other developers, I like to live on the bleeding edge, learning new language features, using the latest tools so naturally one of the things I wanted to see in Windows Azure Web Sites is support for PHP 5.4. I’m pleased to be telling you today in this post that support for Bring-Your-Own-Runtime is now available in Windows Azure Web Sites.

Out of the box, Windows Azure Web Sites supports PHP 5.3 as you can see from the snapshot of the portal below. In this article I’ll explain how to enable PHP 5.4 in Windows Azure Web Sites.

Windows Azure Framework Support

Configure PHP 5.4 Handler Mapping in Web Sites

In order to enable support for PHP 5.4 in your Windows Azure Web Site, you will first need to create a Web Site.

If you haven’t already signed up for a Windows Azure account, get a 90 day free trial of Windows Azure which gives you access to 10 free Windows Azure Web Sites.

To create your first site, I would suggest following one of the many tutorials on the Windows Azure PHP Developer Center.

I’ve created my Windows Azure Web Site, What’s Next?

To bring you up to speed, I’ve created a Web Site using Quick Create, using configphp54 as the dns prefix for my Web Site.

Web Sites
Click on the Name of the Web Site [in my case configphp54] to proceed to the Details page for your site. On the details page you will see top level navigation items [DASHBOARD, MONITOR, CONFIGURE, SCALE, LINKED RESOURCES] listed. Click on DASHBOARD.

In order to be able to deploy files to the site, we’ll need to create some deployment credentials, you can create [or reset] your deployment credentials from the quick glance section of the DASHBOARD.


Click on create [or reset] deployment credentials to be prompted with a dialog box to enter your credentials.

Fill out the user name, new password and confirm password to create your deployment credentials or simply the new password and confirm password to reset your password. Now your web site is ready for FTP or Git deployment.

Next, click on CONFIGURE.

At the bottom of the CONFIGURE page you will see a new section called Handler Mappings.

Handler Mappings are a way to map a Fast-CGI script processors to file extensions in IIS. These script processors are typically console applications which means they may be able to accept additional command line switches. To set up a custom handler mapping you are required to set at least 2 of the three values, let’s quickly go into some more details around Extension, Script Processor Path and Additional Arguments.

Extension: This is the file extension which should be mapped to the Script Processor.

Script Processor Path: This is the field which specifies the absolute path to a Script Processor [in our case this will be php-cgi.exe]. The script processor’s binary and configuration files can be located anywhere within the application root directory which can be accessed using the D:\home\site\wwwroot path.

Additional Arguments: If the script processor supports additional command line switches which you may require, you can configure them in the Additional Arguments input box.

We’re only going to fill out the Extension and Script Processor Path to configure PHP 5.4. Enter the following values into the handler mappings section.


After you type each line, click the checkmark at the end of the line to commit the value and add a new row. Clicking on the checkmark does not save the entries, a save button will show up in the command bar at the bottom of the portal.


Script Processor Path

Additional Arguments




wwwroot is publicly exposed to the internet which could potentially allow remote execution of executable files contained in wwwroot. By default IIS blocks access to the bin directory of any website or virtual directory, which is why it is safe to place the php runtime in the wwwroot/bin directory.

After you are finished, hit the save button that appears in the command bar to commit these settings.

Wait? Where do I get PHP 5.4 for Windows Azure Web Sites?

Before this site will actually work, we need to provide the php54 runtime in the path specified in our handler mappings settings. Download and extract the VC9 x86 Non Thread Safe zip file to the bin directory in your project

Note Your password is the password you typed while creating your deployment credentials above. This password is used for Git or FTP deployment. For WebMatrix, you can use the Publish Profile to load the configuration for a seamless publish experience.image

Trust, but Verify… (Thanks Horatio… Yeah!)

Upload an index.php file which contains a call to phpinfo() to the wwwroot folder.

If you browse to the site you will see that the site is in fact running with the latest version of PHP (5.4.7 at time of writing).


PHP does auto-discovery of the php.ini file by looking in known locations where it is expected to be placed, the first such place it looks is the directory which contains the script processor. This means that you will have access to your own php.ini file.


By Default, the PHP runtime does not have a php.ini file, it is packed with php.ini-development and php.ini-production. Rename php.ini-production to php.ini, open the file and search for fastcgi.logging and remove the preceding semicolon (;) which will uncomment the line fastcgi.logging=0. FastCGI Logging needs to be disabled (0) in the pipeline or it will return a HTTP 500 when you attempt to execute a script.

With Great Power, Comes Great Responsibility

Now that you own the runtime, you essentially own the experience and the security of the application. Be sure to follow the guidance on Best Practices for Configuring FastCGI and PHP to ensure optimal performance and security.

Stay Cloudy my Friends

WebMatrix 2: Available at a Web Platform Installer Near You

WebMatrix v2  hits the shelves yesterday so run out and download it now!. There are many additions to WebMatrix in this launch and I would like to take the time to describe a few of the things that may shock and excite you.

If you aren’t familiar with WebMatrix here is a quick blurb from the product page:

WebMatrix is a free and lightweight web development tool.
Create, publish, and maintain your website with ease.

What is new in WebMatrix 2?

It’s incredible how many features they can plug into WebMatrix and still have it be very lightweight and simple to use. Let’s take a look at some of the newly supported features of WebMatrix 2.

Intelli-Sense & Syntax Highlighting

Ok, so this might not necessarily be *new* to WebMatrix, but it has definitely been expanded. Many of you may be asking, what the $#@! is Intelli-sense? Intelli-sense is autocomplete on steriods, not only does it list the options for what you are currently typing, but it provides information around if what you’re typing is a method, constant or other variable type, it will also provide you with the method signature or additional information about the particular item you have selected in the list. There is intelli-sense and syntax highlighting support for the following languages/frameworks:

  • HTML5
  • CSS3
  • Node.js
  • PHP
  • Javascript
    • WordPress
    • Joomla!
    • Drupal
    • LESS
    • SASS
    • jQuery Mobile

    Yeah, WordPress, Drupal and Joomla! support, WebMatrix is making it easier to extend your favourite Open Source CMS by providing a quick reference to the built in methods of these framework applications.

    Community Oriented

    Now for something everyone can enjoy!

    Web Gallery

    Install a wide variety of Open Source projects directly from the Web Gallery including WordPress, Joomla!, Drupal and phpBB. New items are added to this list on a regular basis, so it could also be a great tool to discover new Open Source Projects.


    Extension Gallery

    Another cool community aspect of WebMatrix is the extension gallery, which allows you to build custom extensions to WebMatrix. The extension gallery is already chalked full of great extensions including Git for WebMatrix, iPhone, iPad & Windows Phone Simulator.

    Mobile Friendly

    Mobile is all the rage right now, so having a tool not only helps you test on mobile device emulators, but actually gets you started with Mobile Friendly Templates and has auto completion for jQuery mobile, it’s like a match made in heaven.

    Cloud Friendly

    Last but definitely not least, the one thing you most likely come to my blog for, THE CLOUD! WebMatrix allows you to deploy to Windows Azure right out of the box. Of course this isn’t the only deployment option, but quite frankly, it’s the only deployment option I’ll be using. Within a few steps you can be publishing an existing site from your hard drive to Windows Azure Web Sites, or pull down that WordPress site you installed using the Windows Azure Gallery for a few quick changes.

    To Learn more about the cloud features, read Announcing WebMatrix 2 by Jonathan Guerin.

    Windows Azure SDK for PHP – ‘PartitionKey’ property value must satisfy is_string.

    When building out an application there are many factors you need to consider, these considerations boil down to functional and non-functional requirements that you as a developer or architect are set out to achieve. In many circumstances, if not all, we are accepting data as an input from a user or other medium, transforming or normalizing that data into something that will help fulfill other requirements of an application.

    In order to fulfill scalability goals it may be necessary to find alternative means to traditional storage, something that was designed with scalability in mind. One such service is Windows Azure Table Storage which is defined as:

    [Windows Azure Storage] Tables offer NoSQL capabilities for applications that require storage of large amounts of unstructured data. Tables are an ISO 27001 certified managed service which can auto scale to meet massive volume of up to 100 terabytes and throughput and accessible from virtually anywhere via REST and managed API’s.

    The topic of Windows Azure Storage Abstractions and their scalability targets is some what out of scope of this post, however, keep in mind that it is important to understand the Windows Azure Storage Architecture and more specifically How to get the most out of Windows Azure [Storage] Tables.

    Integer values for PartitionKey or RowKey with PHP

    If you’ve done your research on designing for scale with Windows Azure Storage and you find that Integer values are what you need for your specific data model, keep in mind that PartitionKey and RowKey values are of type string.

    While this doesn’t seem like a foreign concept you may find yourself in a situation where you have an error while attempting to use integers as strings while interacting with the Windows Azure SDK for PHP. The error you will receive is “PartitionKey [or RowKey] property value must satisfy is_string”. In my particular scenario I was loading my tables by iterating through an array of key/value pairs.

    My array looked like this:

    In which you may expect the key to be treated as a string, which isn’t the case. To understand the reasoning behind this, we’ll go right to the source.

    The key can either be an integer or a string. The value can be of any type.

    Additionally the following key casts will occur:

    • Strings containing valid integers will be cast to the integer type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn’t a valid decimal integer.
    • Floats are also cast to integers, which means that the fractional part will be truncated. E.g. the key 8.7 will actually be stored under 8.
    • Bools are cast to integers, too, i.e. the key true will actually be stored under 1 and the key false under 0.
    • Null will be cast to the empty string, i.e. the key null will actually be stored under "".
    • Arrays and objects can not be used as keys. Doing so will result in a warning: Illegal offset type.

    According to the documentation, you’ll notice that “strings containing valid integers will be cast to integer type”, in order to ensure that the now converted integer is provided to the service proxy as a string, we need to call strval() on the key when providing it as a PartitionKey or RowKey. To provide an example of this consider the following:

    Where addEntity() constructs an entity and inserts it into Windows Azure Table Storage.


    In this post I clarified a potential issue that may arise when iterating over an array with key/value pairs to push entities into Windows Azure Table Storage.

    Stay Cloudy My Friends…

    Windows Azure Training Kit Update Released – August 2012

    Today, My team has released a new drop of the Windows Azure Training Kit, it’s available for download now!

    What is the Windows Azure Training Kit?

    The Windows Azure Training Kit (WATK) is one of the best ways to learn, practice or teach how to leverage Windows Azure and it’s supporting services.

    Official Description

    Windows Azure Training Kit includes a comprehensive set of technical content to help you learn how to use Windows Azure.

    What’s new in the Windows Azure Training Kit?

    This release [August 2012] of WATK includes 41 hands-on labs and 35 presentations.

    Hands-on Labs

    We have pulled in some changes from our GitHub Repository and addressed a number of bug fixes for our hands-on labs for this release. Feel free to Report Issues if you run across a problem in a hands-on lab or presentation.


    This release introduces a new agenda for Windows Azure DevCamps which contains 7 new presentations:

    • DevCamps Keynote
    • DevCamps Websites
    • DevCamps Cloud Services
    • DevCamps Virtual Machines
    • DevCamps Data
    • DevCamps Windows 8 + Windows Azure
    • DevCamps Windows Phone + Windows Azure

    In addition to the new agenda, the following presentations were added to the foundation agenda:

    • Security & Identity
    • Building Scalable, Global and Highly Available  Web Apps
    • Windows Azure SQL Database
    • Windows Azure SQL Federations
    • Windows Azure Reporting
    • Windows Azure Data Sync

    Have any feedback?

    I’d love to hear any feedback that you have in regards to our training kit. Please leave a comment below.

    Stay Cloudy my Friends…

    Using WebMatrix to Develop Apps with PEAR Modules

    If you’re developing PHP on Windows, Microsoft has an IDE that may be of some interest to you, it’s called WebMatrix. WebMatrix is an extremely powerful IDE providing code highlighting for PHP, Node.js, ASP.NET Razor, it even offers code completion for popular OSS CMS platforms like WordPress, Drupal and Joomla. Unlike conventional IDE’s it’s extremely lightweight, despite it’s heavy hitting features.

    One of the oddities of WebMatrix is that is installs it’s own copy of php on your system located in C:\Program Files (x86)\IIS Express\PHP. Normally not a big deal, however if you start building larger applications you’ll probably want to include some functionality which will require a Pear package. This isn’t as straight forward as one would hope.

    Installing Pear in WebMatrix

    Before I send you down a wild goose chase, you can validate that WebMatrix is actually using the php.ini file from it’s own installation, you can do this by including <?php phpinfo(); ?> in one of your php files then run the site. I have also assumed that you have already installed Pear using the instructions.

    When the PHP Information loads you’ll want to check two of the variables first check Loaded Configuration File this will tell you the path of the php.ini file it is reading the configuration information from. Second, you’ll want to check out include_path which will print out the include paths that it will check for addition application code blocks, such as Pear Packages by default this will be .;C:\php\pear.

    Finding the Pear directory on your machine

    To find the path to Pear on your machine open up the command prompt and type pear config-get php_dir, copy the path that is outputted and close the window.

    In order to change the php.ini file, you’ll need to open Notepad with elevated permissions this is due to the file being contained in the Program Files directory which is protected by the Operating System.  Once you have opened the WebMatrix php.ini file from C:\Program Files (x86)\IIS Express\PHP\v5.3 scroll to the bottom of the file and add include_path=".;C:\Path\From\Pear\Config\Output\"

    Oh Great, I did all that and it still doesn’t work

    Before you go and brush your shoulders off, you need to restart IIS Express. The php.ini file is only loaded when the IIS Express process is started, there is no file system watcher set up to monitor changes to the php.ini file.

    Restart IIS Express by clicking on the blue circular arrow (marked restart) in the Sites tray of the WebMatrix Home Ribbon.