Home | Setup Guide | Deployment Guide | Advanced Features

PHP Developer WebRole Framework



INTRODUCTION

Windows Azure Command-Line Tools for PHP Developers creates a deployable package that can be used for both the local Development Fabric and Windows Azure Platform cloud.

This page describes how this command-line tool provides additional command-line functionality for PHP developers:
  • How to edit PHP sources for Web Role, a customized web application that will be packaged and deployed within Windows Azure.
  • Choice of PHP Libraries
  • Choice of Windows Azure Data Storage options
  • Choice of PHP Extensions


Environment Requirements

First and foremost, you need to complete the Setup Prerequisites before being able to use this command-line tool.


Quick Overview of Windows Azure Service Architecture

The architecture of a service hosted in Windows Azure is based on discrete scalable components built with managed code. These components are termed roles.

A service hosted in Windows Azure implements one or more roles. A service may run multiple instances of a role. Within Windows Azure, running instances of a role are replicated across multiple computers to implement all or part of the functionality of a service.

Windows Azure currently supports the following two types of roles:
  • Web role: A web role is a role that is customized for web application programming.
  • Worker role: A worker role is a role that is useful for generalized development, and may perform background processing for a web role.

A service must include at least one role of either type, but may consist of any number of web roles or worker roles.

This command-line tool supports packaging and deploying Web roles and Worker role.


PHP DEVELOPMENT FRAMEWORK

This tool provides a framework for PHP developers to be able to perform edits of their web application's PHP sources, which will be added to packaging that is deployable to the Windows Azure platform.

Initially, the developer may provide their own PHP sources using --source (-s) parameter or allow the tool to add default PHP sources (index.php and Web.config) which will be copied into a project's WebRole directory created by the command-line tool.

Allow the command-line tool to perform one successful pass in creating the initial framework. It is not necessary to deploy the initially create package to the local Development Fabric by using --runDevFabric (-u), because the focus is creating a framework for PHP development and not deployment.

After the initial pass of the command-line tool, PHP developers can start editing the PHP content and Web.config within the created WebRole directory.

As more functionality by edited PHP sources are added within WebRole directory, PHP developer can run again the same command-line parameters to perform a deployable package, and even deploy this package to Development Fabric.

NOTE: When re-running this tool after an initial pass with the same project name --project (-n) and same workspace --target (-t), and without --cleanRebuild (-f), then the tool will not delete the WebRole directory thereby not losing changes to PHP sources and only re-create Service directory which is used to create a new packaging.

CAUTION: Using tool's parameter --cleanRebuild (-f) performs a complete cleanup of the tool and the project. It deletes all downloaded PHP resources, and deletes both of the project's WebRole and Service directories.


CREATING & EDITING PHP SOURCES WITHIN FRAMEWORK

Here will be explained how PHP developers can use the provide framework to edit their PHP sources.

The following example command-line run creates a Windows Azure package for deployment.

php package.php -n=testSimple -r="C:\Program Files\PHP" -t=..\workspace\ -ufb -i=3


The command-line parameters provided for this run are:
  • --project (-n) - Create deployment package with this project name: testSimple
  • --phpRuntime (-r) - Provide location of PHP Runtime: "C:\Program Files\PHP\"
  • --target (-t) - Directory for creating both of the project's WebRole and Service Directories: ..\workspace\
  • --runDevFabric (-u) - Enable deployment of package into Dev Fabric.
  • --cleanRebuild (-f) - Deletes all downloaded PHP resources, and deletes both of the project's WebRole and Service directories.
  • --webroleInstances (-i) - Creates 3 WebRole instances within Development Fabric

The following link presents a run of command-line with the aforementioned parameters:

C:\...\WindowsAzureCmdLineTools4PHP > php package.php -n=testSimple -r="C:\Program Files\PHP" -t=..\workspace\ -ufb -i=3

===============================

  1.      Validating parameters.

  2.      Validating Tool's PHP Resource. .

  3.      Validating Workspace. . . . .

  4.      Validating PHP Sources for WebRole directory.

  5.      Removing "testSimple" Service if deployed upon Dev Fabric. . . . . . .

  6.      Creating workspace for "testSimple" Web Role and Service. . . . . . .

  7.      Adding resources to Web Role. . . . . . .

  8.      Adding resources to Service Directory.

  9.      Configuring "testSimple" Web Role. . .

  10.     Packaging "testSimple" Web Role. . .

  11.     Validating Service Directory.

  12.     Configuring "testSimple" Service. .

  13.     Packaging "testSimple" Service. . .

  14.     Successfully packaged "testSimple"

===============================
"testSimple" Web Role is ready for development.
WebRole Location:
         C:\...\workspace\testSimple_Build\testSimple_WebRole
===============================

===============================
"testSimple" Deployment Package and Configuration is ready.
Package Location:
         C:\...\workspace\testSimple_Build\testSimple
WebRole Package: testSimple.cspkg
Service Package: ServiceConfiguration.cscfg
===============================

  15.     Deploying "testSimple" Service upon Dev Fabric. . . . . . . . . . .

===============================
"testSimple" Web Role is running in Dev Fabric.
Deployment ID: 587
Endpoint URL: http://127.0.0.1:83/
===============================

Success: Normal Exit
===============================


After running tool, the tool creates a workspace if does not already exist, and then creates the project's WebRole and Service Directories within it:

adv1_workspace.png


WebRole Directory and PHP Sources

Within the tool created WebRole directory, it contains default PHP source index.php and Web.config. Also included is Windows Azure SDK for PHP Developers within directory labeled \Microsoft.

It is here within the project's WebRole directory can PHP developers edit and add PHP sources that will be packaged for Windows Azure deployment.

adv2_webrole.png

Worker Role Directory and PHP Sources

Within the tool created WorkerRole directory, it contains default PHP source index.php and Worker role application folder.

It is here within the project's WorkerRole directory can PHP developers edit and add PHP sources that will be packaged for Windows Azure deployment.

adv6_workerrole.png


Service Directory and Service Package

Within the tool created Service directory, it contains the created Service Package performed by the Windows Azure SDK's CPack command-line tool.

What is a Service Package? It is what contains the Service Definition for your Cloud Service along with the content and binaries for each of the web role.

A Service Package comes in two flavors.

The first flavor being a folder structure labeled ServiceDefinition.csx. It contains the layout for the role binaries, which include WebRole PHP sources and PHP resources (PHP binary, ini, and extensions). This is what is used to run the Cloud Service on the Development Fabric.

The second flavor of the Service Package is the single file version (cspkg file extension). This is the file that you upload (along with the Service Configuration file) to the Windows Azure cloud to run your service.

adv3_servicepkg.png

Deployed Project using Development Storage

After this project is packaged and deployed to Development Fabric, --addTemplates (-b) will include PHP sample code that will access Blob and Table services services Development Storage, and SQL Azure.

adv4_deployed.png

--worker-role (-w) , --worker-role-startup-script (-b) And --webroleInstances (-i) = 3 will deploy 3 WebRole instances and 1 WorkerRole instance within Development Fabric.

adv7_devfabric.png

Last edited Dec 15, 2010 at 4:31 AM by satish_nikam, version 12

Comments

No comments yet.