PHP 5.5.0 for Windows Released!

php-med-transToday is an exciting day as we welcome the availability of PHP 5.5.0 [Release Announcement]. The team here at Microsoft has been busy preparing PHP 5.5.0 for Windows which has a number of updates which I will cover in this post.

IMPORTANT

With the release of PHP 5.5.0, the PHP Community has also announced that PHP 5.3 will go into “Security Only” maintenance, which will last for a period of 1 Year, at which time PHP 5.3 will enter End of Life (EOL).

What’s New in PHP 5.5.0

The most notable change to PHP 5.5.0 is the inclusion of Opcache extension which is to be bundled into the language. There are a number of other enhancements including:

Language Bundled Opcache Extension

As anyone who develops PHP code knows, an opcode is important to speed up the execution of the script. This is done by caching compiled interpreted PHP code, so that the compiler doesn’t need to be used on each request. If a compiled version of the requested script is cached, the compiler is bypassed and sent directly to the executor. The Opcache extension was contributed by Zend, and is based on their Optimizer+ extension.

Good news for those running PHP on Windows is that Opcache is supported on Windows and performs quite well over the current version of WinCache. You can see some performance numbers below with the new Opcache support in PHP 5.5.0.

Zend contributed Opcache under the PHP LICENSE and the source code is available on GitHub.

What’s New in PHP on Windows

Over the past several years, Microsoft has been heavily investing in PHP on Windows working towards better support for PHP in IIS. In recent years, additional work to ensure that PHP not only work on Windows Azure, but to ensure that PHP is a first class citizen on the platform.

Microsoft Contributors to PHP

Microsoft has two contributors to the PHP project who are within the top 10 committers within the last 12 months. Pierre Joye, one of the two contributors mentioned above, has the most all time contributions to the project with over 6000 commits according to Ohloh.net.

There is a great deal of collaboration between the PHP community and the Microsoft Open Source Technology Center (OSTC) (which is responsible for Q&A and PHP builds for Windows) in order to ensuring extensions are updated amongst other works.

Performance Improvement for PHP on Windows

There have been some major improvements surrounding performance of PHP on Windows. The improvements include moving to the VC11 compiler as well as the new Opcache extension explained above.

Moving PHP Core and Extensions to VC11

There have been a number of improvements which have come out of moving the PHP source and dependencies to be compiled under the latest VC11 compiler. Taking advantage of Profile Guided Optimizations (PGOs) which is a runtime compilation optimization which leverages profile data collected by running performance centric usage scenarios to build an optimized version of an application. You can read more information regarding PGO from the C++ Compiler team blog, I would suggest Profile Guided Optimization: Under the hood and Build faster and high performing native applications using PGO. To better understand how the PHP binaries took advantage of PGO, read Speed up Windows PHP Performance using Profile Guided Optimization (PGO).

Looking at the Numbers…

The team is seeing some significant performance numbers captured in the below tables. The following performance metrics were captured from a machine with the following configuration:

Dell R710
CPU – Intel Quad core @ 2.26Ghz (x2) L5520
Memory – 12GB RAM
HD – 147GB SAS RAID 1
NIC – 1Gbps Intel
Windows Server 2012

Note: Performance metrics are in Transactions per Second (TPS)

PHP Performance on IIS

As you can see, there is a range of 7-15% increase in performance over PHP 5.4 with no caching enabled in IIS against some of the industry leading CMS applications. Opcache significantly increases performance over PHP 5.4 with WinCache, anywhere between 25-152% increase in performance on IIS against the same applications.

PHP-PERF-IIS75

PHP Performance on Apache 2.4

If you are leveraging Apache 2.4 on Windows, you may see an 8-19% increase in performance over PHP 5.4 with no caching enabled. When testing with Opcache enabled over PHP 5.4 with APC caching in Apache, you may see performance gains of between 12-119% on Apache 2.4.

PHP-PERF-APACHE24

Wrapping Up

It’s exciting to see the PHP language continue to grow and evolve as well as the collaboration between the PHP community and Microsoft to continue to advance the support of PHP on Windows and Windows Azure.

Installing CakePHP from the Windows Azure App Gallery

In my previous post Application Frameworks now part of the Windows Azure Web Sites Gallery I introduced the concept of ready to install application frameworks which can be provisioned as part of a new Windows Azure Web Site. The benefits include having a ready to go starting point for building out your application with a tested and fully capable package which includes common Application Settings as well as the proper configuration for IIS.

Today, I’m happy to announce a new addition to the App Frameworks section of the Windows Azure App Gallery, CakePHP. Let’s take a look at the steps to get CakePHP running in Windows Azure Web Sites using the new Gallery item.

Setup CakePHP on Windows Azure Web Sites

To follow along with the example below, sign up for a Windows Azure Free Trial.

In order to provision a Web Site from the Windows Azure App Gallery we must first sign into the Windows Azure Management Portal. Once you’ve logged into the portal you will see the command bar at the bottom of the browse, click New.

drawer-waws-new

This will open the drawer and enable you to select from a variety of different services which you can provision, for this example we’re interested in Web Sites. Select ComputeWeb Sites > Gallery.

drawer-waws-fromgallery

The gallery modal will pop up and allow you to select from a number of well-known open source CMS, Frameworks and other tools.  Select App Frameworks > CakePHP or scroll through the list to find CakePHP.

At the time of writing this article the CakePHP version in the Gallery was 2.3.6.

windowsazure-websites-gallery-appframework

Once CakePHP is selected, click the next arrow at the bottom of the screen to advance to the Configuration page in the wizard.

websites-configure-cakephp

In order to configure a secure deployment of CakePHP, the Cake Foundation suggests including a Security Salt and Cipher Seed. The Web Sites team has conveniently surfaced those settings to the Configuration page, which will get injected into the proper configuration setting in the app/Config/core.php file.

During the configuration, you can select an existing MySQL Database or create a new MySQL Database with your new site. If you needed to create a new MySQL Database, you will receive this screen which will ask for the database name, a region to deploy the database in [Note: It’s a good practice to deploy your database in the same region as your application to reduce latency], you will also need to accept the terms from our partner ClearDB who supplies the MySQL Databases in Windows Azure.

websites-mysql-cakephp-database

That’s it! After clicking the checkmark to complete the wizard your new Web Site will start to provision which includes a configured version of CakePHP which is a great starter point to your next CakePHP Application.

windowsazure-website-site-listing

Once the Status changes to Running, you’re ready to view your new site. You can do this as simply as clicking the BROWSE icon in the Command Bar.

drawer-waws-browse

Congratulations, you have yourself a brand new CakePHP Installation in Windows Azure Web Sites.

WindowsAzure-WebSites-CakePHP

CakePHP is setup, Now what do I do?

Now that the CakePHP Framework is in place it’s time to start building an application. To do so, you’re going to need the source on your local machine.

Download your Web Site files with Git

With Windows Azure Web Sites you can deploy using many source control repositories, this includes Git. However, Git isn’t enabled by default when you create a site from the gallery, so lets find out how to enable Git Deployment (and in our case, a remote repository to clone from).

If you click into the details of your new Web Site in the Windows Azure Portal, you will see a Quick Glance section on the DASHBOARD. Click on Set up deployment from source control to create a new repository in your Windows Azure Web Site.

 

websites-set-up-source-control

Like I said above, there are many options for source control systems, select Local Git Repository then the next arrow to continue.

websites-setup-source-control-git

It may take a few seconds for your repository to be created, so this notification will keep you amused in the meantime.

websites-create-git-repo

Once the repository is created, the portal should redirect to the DEPLOYMENTS tab. Copy the Git URL, you’ll need this to clone your repository on your local machine.

websites-copy-git-url

On your local machine, open Git Bash or your favourite Git command line utility, type the following pasting the git url you copied above in place of <git-url> below, then hit enter.

git clone <git-url>

local-clone-website-repo

You now have a local git repository of your CakePHP Application.

You may have noticed both the Vendor and Plugins directories are missing, this is because they are empty and Git does not track empty folders. Simply create the folder locally and place a file in the directories in order to upload third party code or plugins, respectively.

Download your Web Site files with FTP

To download your Web Site files with FTP you will need your favourite FTP tool, this could be a number of different tools including the command line. Here are the steps you will need to take to configure FTP downloads from your site, I’ll leave the actual downloading up to you.

On the DASHBOARD screen in the portal under the Quick Glance section, you will need to set (or reset, incase you forgot) your deployment credentials. Click on the link which allows you to set the deployment credentials.

websites-setup-deployment-credentials

Fill out the form providing your username, password and confirm password.

websites-set-deployment-credentials

Once you’ve set your credentials, scroll a down the Quick Glance section until you find your FTP or FTPS Host Name.

websites-ftp-links

Notice that your FTP User is a combination of the web site name and the user name provided above, the password is the password which was created when you set your deployment credentials.

Enjoy developing with CakePHP!