Josh Holmes's complete blog can be found at: http://www.joshholmes.com

Items:   6 to 10 of 219   « Previous  | Next »

Sunday, December 12, 2010

It’s with great excitement that I let you know that I’m opening a new chapter in my families life. We’re moving to Ireland!

I’ve taken a job with Microsoft Ireland as an Architect Evangelist with a heavy focus on startups, web and cloud computing all of which are hot topics in Ireland right now.

Quick FAQ:

  • Are you staying with Microsoft?
    • Yes – I’m staying with Microsoft. Actually, I’m even keeping the same job title of Architect Evangelist.
  • Are you still going to be an evangelist?
    • See the previous question – I’m even keeping the same job title… :)
  • Are you Irish?
    • Some small percentage probably but not enough that it matters. My wife is about half Irish though. She’s traced back her family tree, O’Healy and O’Hearn, to Country Clare and County Roscommon but we’re not in contact with any remaining relatives in Ireland. Most of them are in Canada, Australia or the US so honestly, that wasn’t one of the major factors in us moving over.
  • Then why Ireland?
    • I’ve felt a deep connection to Ireland since the first time that I visited almost two years ago. I really enjoy the people, the culture, the scenery and the spirit of the country. There’s a true “Work Hard, Play Hard” mentality that’s been my philosophy since I was a kid. I’m really excited about the opportunity to work with the extremely innovative and passionate people in Ireland.
  • Isn’t Ireland’s economy in a touch of trouble right now?
    • Dude. I currently live in Michigan. I understand poor economies. Besides, that’s one of the reasons that I’m really excited to work with startups in my new position.
  • Where will you live?
    • For right now we, Phoebe and I, are concentrating on looking in the South Eastern part of Dublin which would place us within easy striking distance of the Microsoft office and a short train ride downtown. Also, as Phoebe has pointed out to me more than once, that’s where Bono lives. :)
  • Is this a permanent move?
    • Honestly, no idea. We are selling the house in Michigan (anyone want a big and cheap house in Manchester, MI?) as part of the move so this is a long term (well over a year) move. That does not mean that we’re moving over forever but we don’t have a specific length of time that we are looking at.
  • What’s your biggest concern?
    • I’ve got two. Selling my house in Michigan  (the housing market here is, to put it lightly, soft) and getting decent coffee. I’ve already been warned that I’ll likely have to convert over to tea but that’ll be at tough sell for me. It’s not that I have anything against tea, it’s more that I’m such a coffee addict and I’m fairly particular about it.
  • Are you going to disappear completely?
    • Yeah, you know me. I hide on the web and never go to conferences… No, wait, strike that and reverse it.
    • No, you know me. I’m very active on the web and go to a ton of conferences and I don’t expect that to change.
  • When will I see you again?
    • It depends… If you’re in Ireland, soon! If not, I need to work out my travel and conference schedule still. I will be at CodeMash and I’ll be at Symfony Live in Paris. Beyond that, I’m not sure yet.

I’m really looking forward to living and working in Ireland and making all kinds of new friends. I’m sad to be moving away from my great friends and co-workers here in the US, Michigan in particular but technology is a wonderful thing and we can stay in contact.

My email address won’t change. It’s josh(period)holmes(at)microsoft(period)com.
Connect to me on Plaxo and that’ll update my phone number when I get the new one.
My twitter handle is joshholmes.

If you’re in Ireland, all the same contact info applies – please reach out. I’m looking forward to meeting you!!!


Friday, November 12, 2010

Slide1_thumb[1]Mark Brown and I did a talk at ZendCon last week on how well PHP runs in IIS and more specifically, some things that you should do in order to make it run really well on IIS.

Quick warning, this is an unfortunately bullet pointy slide deck for me. Mark created the original deck that this talk was born from but I’m responsible for delivering it at ZendCon and for posting it here. :)

Mark is with the Web Platform Team and a good guy to know. He saved my tail on this one. My voice was killing me and he stepped in and did 80% of the talking. I talked through the demos but he hit all of the talking points.

Slide2_thumb[1]

We started the talk off with a little walk down memory lane. The reality is that many people who have tried PHP on Windows and really didn’t like it did so on previous version of IIS under CGI. Issue was that PHP on older version of IIS with the old school CGI handler It wasn’t until 2007 when FastCGI came out that things started to get interesting on the IIS stack.

Slide3

IIS 7 came out starting with Win7 and SQL Server 2008. It’s gotten a huge overhaul, not just in terms of PHP but terms of it’s entire architecture. To start with, the attack surface is greatly reduced as it does a very lightweight install and then you have to turn on anything that you want to run. Out of the box, it only serves up static files and you have to turn on ASP.NET, PHP and anything else.

The new modular architecture is fantastic. It used to be that you had to write any extension or modules in C++ or at least do a C++ wrapper around managed code. Now you can write your modules in .NET and load them directly. These modules can plug into any point along the processing pipeline and do anything from handling authentication to manipulating the incoming or outgoing streams.

Additionally the per application configuration has gotten tremendously powerful and can do anything from setting up the cache handing to URL Rewrite rules (more on this in a bit) to setting up the modules and handlers that can plug into the IIS processing pipeline.

Slide4Another great improvement is FastCGI. If you are doing PHP on IIS, you need to be using FastCGI. It is the CGI handler on IIS 7 and is available as a download for IIS 6. There were some really fundamental changes that were made. One of these is that under CGI, IIS spun up a new process for every request. This is a really expensive thing to do. Under FastCGI, it does some awesome things where it spins up a configurable number of processes and then recycles those same processes over and over again. There’s a ton of other great improvements here including recycling the PHP pool when the php.ini changes so you don’t have to manually restart IIS and much more.Slide5

WinCache is not installed by default on some IIS instances but you should check to make sure that it is. It’s distributed through Pecl at http://pecl.php.net/package/WinCache. It provides a ton of great enhancements including Opcode Cache, File Cache, Relative File Path Cache, Session Cache and User Data Cache. The awesome part is that all you have to do to take advantage of the first 3 is enable WinCache in your PHP.ini file. Just doing this has shown anywhere from a 100% to a 400% increase in performance depending on the application and what it’s doing.

To take advantage of User Data Cache, you need to write a little bit of code but all of the functions have the same function signature as APC. See the little bit of code that had to be written for Joomla support for WinCache for an example.

Once you’ve installed it, there’s a great script that will help show you what’s in WinCache at any given point – more details at http://blogs.iis.net/donraman/archive/2009/10/20/wincache-1-0-rc-using-the-statistics-page.aspx

Slide6

URL Rewrite is a very powerful rewrite engine for IIS 7 so you no longer have to look at external rewrite engines such as ISAPI Rewrite. Remember that this is not installed by default as IIS 7 installs with the smallest set of features possible. If you’re an Apache user right now, the easiest way to get started is to simply import your .htaccess file and it will pull in and convert your rules to the web.config file that IIS 7 uses.

One quick example is the one that I use for WordPress to enable pretty urls.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webserver>
    <rewrite>
      <rules>
        <rule name="wordpress" patternsyntax="Wildcard">
          <match url="*" />
          <conditions>
            <add negate="true"
                 input="{REQUEST_FILENAME}" matchtype="IsFile" />
            <add negate="true"
                 input="{REQUEST_FILENAME}" matchtype="IsDirectory" />
          </conditions>
          <action url="index.php" type="Rewrite" />
        </rule>
      </rules>
    </rewrite>
  </system.webserver>
</configuration>

But it can do much more than just dealing with simple redirection. It can match on wildcards, regular expressions and a ton more.

Slide7Another way to squeeze some performance out of PHP on Windows is to migrate to PHP 5.3. The builds of PHP 5.2 and previous for Windows are built with VC6 which is a 10 year old compiler. The new PHP 5.3 builds are built with VC9 which is a modern compiler with a lot of great optimizations. In addition, earlier versions of PHP on Windows did almost everything through a POSIX translation layer just to get it to work. The Windows support in PHP 5.3 has been rewritten to run natively on the Win32 APIs rather than having to go through the translation layer.

Now, if you really need to check out building your own Performance Guided Optimization build of PHP specifically for your box.

Slide8

The next thing look at is the new PHP Manager released on CodePlex. The very short version is that it allows you to run different versions of PHP on the same server for different applications. It manages  the php.ini file and PHP extensions per application as well. You can even connect to it remotely through the IIS Remote Administration Tool so you no longer have to have write permissions on the PHP directory on the box to manage things.

Slide9

Connecting to SQL Server has been a pain point as well for many years. In 2008, however, the SQL Server team released the new native drivers for PHP on Windows. Then this year (2010 for those those that are reading this later… :) ), the SQL Server team released PDO support for PHP on Windows. Drupal 7 is actually already tested against this and ready to go.

The question was raised about when we’ll have Linux drivers for SQL Server and I’ll give the same answer here that I gave on stage. The SQL Server team has received that feedback and it’s on the radar. I don’t have any insight into the SQL Server team’s roadmaps or future plans and I have no idea if it will ever happen or when it would happen if it were on a roadmap somewhere but I do know that the SQL Server team has heard that request from multiple sources and they listen to their community. Is that non-answer enough for you? :)

Slide10

Another really useful utility is the IIS Database Manager. The easiest way to install this is through the Web Platform Installer. This plugin to IIS Manager helps you manage your databases whether they are SQL Server or MySql. It actually looks in your web.config file for connection strings and will show those databases in the "quick open" area or you can browse to your database and open it specifically. This is not going to replace your favorite DBA tool but it will give you quick and easy access to do simple things remotely without having to crack open extra ports and all that.

Slide11

Many of the most popular PHP apps out there run really well on IIS and are easily installed through the Web Application Gallery and the Web Platform Installer.

Get WordPress

Get Joomla!

Get Drupal

But don’t stop there, you can check out all of the applications in the app gallery until you find the ones that make the most sense for you.

Slide12

In addition to all the work on the core language and getting it to run really well, Microsoft’s been working hard at making things like SQL Server reporting services work with the SQL Server Reporting Services SDK for PHP. PHP works really well with Silverlight as Silverlight does a great job with restful services as well as having the best video experience out there through the adaptive streaming technology. I was talking to a PHP developer at ZendCon who does a lot of video and his shop used to have to buy 5 or 6 different bit rate videos to cover the different bit rates that their clients needed and they had to store all of that video somewhere. Now with Silverlight, they buy one video and store one video and all of their clients are shown the correct bit rate for their connection.

Slide13

We’ve been doing a ton with the PHP community. Many of the things that we talked about in this talk are out there at open source.

WinCache is on PECL and licensed under BSD.

WinCache support for Joomla! which we write is released under GPL 2.

SQL Server Driver for PHP is under Apache 2.0

I’m not going to drain the list but most of the work by the Interoperability Bridges team is released as open source.

We listen and interact on the PHP forums. Many of us can be found on IRC. We work with core team members from PHP and many of the top applications to help decide what are our next features, products and more. It’s been a really exciting ride the last 3-5 years here at Microsoft in the PHP and open source space.

Slide14

The quickest and easiest way to get started with PHP on IIS is through the Web Platform Installer. This wizard style installer will let you pick an application and not only install that application but it will determine what the dependencies are for it, configure your web platform and install all of those dependencies. And it’s language neutral installing both ASP.NET and PHP applications easily.

Slide15

In summary, PHP on IIS has come a long way in 5 years. It’s a viable choice not only for development but for production. Performance, stability, configurability and more have all improved dramatically through technologies such as FastCGI, WinCache, SQL Server and very importantly IIS 7. Check it out. I think you’ll be pleasantly surprised.

The quickest and easiest way to check it out is through the Web Application Gallery.

Slide16Slide17

Check it out and let me know what you think.


Thursday, November 11, 2010

phpUntitledI got a question the other day about running both ASP.NET and PHP on the same server and whether or not it works. The short answer I gave is “Yes”. The longer answer, I’m going to give here.

In point of fact, both ASP.NET and PHP work really well on the instance of IIS. They can’t share  session state but otherwise it’s a very peaceful existence.

First of all, PHP runs really well on Windows and IIS. There’s a lot of stuff that you probably didn’t know about it. Mark Brown and I did a talk about that at ZendCon – I’ll do a full write up of that talk sometime soon.

There are a ton of great resources out there for running PHP on Windows very well.

Easiest way to install PHP on Windows
Official site for PHP on IIS – Lots of good walk throughs and how to guides here.
RuslanY’s blog about IIS, FastCGI, PHP and other interesting stuff.
Brian Swan’s blog about PHP, SQL Server and more.
PDO driver for Microsoft SQL Server
SQL Server Reporting Services SDK for PHP
PHP: WinCache
Performance improvement in Joomla using WINCACHE user cache – great info on leveraging user cache.
Interop resources from Microsoft and PHP
URL Rewrite module for IIS7

I could keep going but this post is about running both ASP.NET and PHP on the same IIS instance.

Mike Volodarsky wrote a great article on leveraging the integrated pipeline in IIS7 that included leveraging ASP.NET Forms Authentication to restrict access to a PHP application. I’m not going to rehash that entire article but rather recommend that you leverage the applications that are up in the Microsoft Web Application Gallery such as Gallery. These applications are really simple to get set up on IIS7 through the wizard style installer in the WebPI.  

The first scenario that we’ll look at is a PHP application running as a subdirectory on the same server as an ASP.NET application. The first thing I’m going to do is get an ASP.NET application up and running through the Web Platform Installer (WebPI). I’m going to use BlogEngine.NET this demo. If you don’t already have the Web Platform Installer, it’s easy to install by going to http://www.microsoft.com/web/gallery/ and clicking "Install” next to any of the applications that you want to install. If you already have it installed, simply launch the Web Platform Installer, find BlogEngine.NET and start the wizard.

firstIf you want the application to be the root of the web server, then on the page where it’s asking about location, clear out the ‘application name’ field. It makes sense once you see it but it took me a second the first time that I tried it. I already had all of the dependencies installed for BlogEngine.NET so the rest was just following the wizard.

secondOnce BlogEngine.NET is installed, I can browse out to it and make sure that it’s all working. I can, if I want, do some configuration and change the title, skin and the like. However, that’s not the point of this little exercise so I’m going to skip it for the moment.

Now I’ve got an ASP.NET application up and running as the root of my server. Now I need to place the PHP application on the box to show them running side by side. The quick one that I want to install is Gallery which is a well known PHP application that does a good job at photo galleries. There are a number of galleries listed in the Web Application Gallery but the one that we want is “Gallery”.

ThirdAgain, I’m going to install the application through the WebPI. I have most of the dependencies installed already but I’m going to use SQL Server because I’ve already got one application using it, I might as well use it for the other. That’s going to require me to install the Microsoft Driver for PHP for SQL Server 2.0 and it’s associate that helps with IIS specifically. The good news is that these dependencies are selected and installed automatically by the wizard. Once the WebPI installer finishes, click “Launch Website” and finish out the installer.

At this point I’ve got BlogEngine.NET running at http://localhost and Gallery running at http://localhost/gallery proving out scenario one where PHP can run in a sub-directory under ASP.NET. The opposite is true as well but unless someone specifically requests it, I’ll assume that you can switch this example around and do it the other direction where you have a primarily PHP site with a little bit of ASP.NET running on the same server.

These different applications can share HTTP Handlers, URL Rewrite Rules, security rules (as stated in Mike’s article) and a bunch of different aspects of IIS. What they can’t share out of the box is session state. ASP.NET can store session in a number of places, including SQL Server and theoretically it’s possible to write a custom PHP session handler that would read from that same store but I haven’t tried it so I can’t guarantee that it’ll work.

In future posts, I’ll take a look at integrating HttpModules and HttpHandlers into the PHP pipeline and see how that works. In the mean time, have fun mixing and mashing technologies.


Thursday, October 21, 2010

image I’ve been playing with Zend’s SimpleCloud API for the webcast that I’m doing with Zend today. I started with the Zend Framework Quickstart tutorial but changed out the backend to hit the Azure Tables and such (well kinda – I used Zend Studio 8 Beta 2 and didn’t use the ZF tool but I still created a little guestbook). I’m going to expand this example to include blob storage and queues as well in the near future but at the moment, I’m just going to hit the Azure Tables.

update – here are the slides for the presentation:

To get started, I downloaded and installed the Zend Framework CE 1.10 and Zend Studio 8 Beta 2. Then I downloaded and installed the Windows Azure SDK. imageThe last bit that I needed was the Windows Azure 4 Eclipse which will install inside of Zend Studio since it’s built on Eclipse. To install it, open up Zend Studio/Eclipse and select Help | Install New Software to open up the dialog. Then click Add… and fill in the location as http://www.windowsazure4e.org/update. Click OK, select the Windows Azure for Eclipse Toolkit and follow the rest of the wizard to install it. At this point, I’ve got all of the software installed that I need to install and am ready to start coding.

Creating the Project

Before I create the project, a quick tip is that it’s a lot easier to work with IIS if you move the your Eclipse Workspace to c:\users\public\ZendWorkspace (I’m on Windows 7 so that’s where my public documents are). One more quick step is that I give IUSER Read and Execute permissions on the workspace.

imageOnce I’ve moved my workspace, in Zend Studio, select File, New Zend Framework Project.

Name the project SimpleCloudDemo.

Select “Create new project in Workspace”. I tried creating the project on a local server to skip a few steps but that didn’t work so well as you have to be an administrator to write to the c:\inetpub\wwwroot location. Instead, we’ll just map a virtual directory in IIS in a few moments.

Make sure that Zend Framework default project structure is selected (should be the default).

Click Finish. This will create basic project structure that you’ll need to get started. The Zend Framework is a MVC style framework.

To finish setting up the project we need to include the framework bits and the API bits so that we have everything in a nice portable folder. Copy in the C:\Program Files\Zend\ZendServer\GUI\library\Zend directory to [project dir]\library.

Lastly, download the SimpleCloud Api from http://simplecloud.org/download and unzip it to the [project dir]\library directory.

Mapping the IIS Virtual Directory

Now we want to be able to test and make sure that everything is installed correctly and that the project works. To do this, we’re going to map a IIS virtual directory.

image Open Internet Information Services (IIS) Manager and expand the tree on the left hand side until you find the default web site.

Right Click on the Default Web Site and select Add Virtual Directory…

Fill out the Alias with something simple to remember such as simpleclouddemo and fill in the Physical path with the directory to [your project directory]\public. Since I moved my workspace up above, the full Physical path that I entered is c:\users\Public\ZendWorkspace\SimpleCloudDemo\public

image Now, browse to the virtual directory at  http://localhost/simpleclouddemo.

The one other thing that I’ll do that’s IIS specific is create a URL_Redirect rule that will make sure that the Zend Framework actually gets all of the calls rather than the calls just going into the IIS bit bucket. The easiest way to do that is to create a file called web.config in the public directory.

<?xml version="1.0"?>
<?configuration>
  <?system.webserver>
    <?rewrite>
      <?rules>
        <?rule name="Main URL Rewrite Rule" patternsyntax="Wildcard">
          <?match url="*" />
          <?conditions>
            <?add negate="true" input="{REQUEST_FILENAME}" matchtype="IsFile" />
            <?add negate="true" input="{REQUEST_FILENAME}" matchtype="IsDirectory" />
          <?/conditions>
          <?action url="index.php" type="Rewrite" />
        <?/rule>
      <?/rules>
    <?/rewrite>
  <?/system.webserver>
<?/configuration>

At this point you should have the project up and running. Now we’re ready to start slinging code.

Creating the Model and Azure Table

We’re going to dive right in and start creating the model and the Azure Table.

The first thing that we’re going to create is the Guestbook model class itself. Create a new PHP file named GuestBookModel.php in the /application/models directory as follows.

<?php
// application/models/GuestbookModel.php

class Application_Model_Guestbook extends Zend_Service_WindowsAzure_Storage_TableEntity
{
	/**
	* @azure comment Edm.String
	*/
	public $comment;
	/**
	* @azure created Edm.String
	*/
	public $created;
	/**
	* @azure email Edm.String
	*/
	public $email;
}

Couple of things that are interesting here.

  1. Notice that the class extends (read inherits for those of you that don’t do PHP heavily) Zend_Service_WindowsAzure_Storage_TableEntity. This parent class gives us the other required fields such as a PartitionKey, RowKey, TimeStamp and the like.
  2. Next, notice the @azure comments in front of each of the variables. This gives typing information to the Azure Table storage engine for comparisons, sorting and storage optimization. The possible choices there are:

Property Type Details
Edm.Binary An array of bytes up to 64 KB in size.
Edm.Boolean A Boolean value.
Edm.DateTime A 64-bit value expressed as UTC time. The supported range of values is 1/1/1601 to 12/31/9999.
Edm.Double A 64-bit floating point value.
Edm.Guid A 128-bit globally unique identifier.
Edm.Int32 A 32-bit integer.
Edm.Int64 A 64-bit integer.
Edm.String A UTF-16-encoded value. String values may be up to 64 KB in size.

The next thing to do is create the GuestBookMapper in the application\models directory.

<?php
// application/models/GuestbookMapper.php

class Application_Model_GuestbookMapper
{
	protected $_cloudTable;
	protected $TABLE_NAME = "guestbook";
	protected $PARTITION_KEY = "guests";

    public function setCloudTable()
    {
    	//This constructor takes account parameters for the live azure account
    	//Goes to Dev Storage if you don't pass in any parameters.
    	$tableStorageClient = new Zend_Service_WindowsAzure_Storage_Table();
		$this->_cloudTable = $tableStorageClient;

        return $this;
    }

    public function getTableStorageClient()
    {
    	if (null == $this->_cloudTable) {
            $this->setCloudTable();
    	}
        return $this->_cloudTable;
    }

    public function fetchAll()
    {
    	$tableStorageClient = $this->getTableStorageClient();

        if ($tableStorageClient->tableExists($this->TABLE_NAME))
        {
    		return $tableStorageClient->retrieveEntities($this->TABLE_NAME, "", "Application_Model_Guestbook");
        }
    	return null;
    }

    public function save(Application_Model_Guestbook $guestbook)
    {
    	$tableStorageClient = $this->getTableStorageClient();
        if (!$tableStorageClient->tableExists($this->TABLE_NAME))
    	{
    		$tableStorageClient->createTable($this->TABLE_NAME);
    	}

    	$guestbook->setPartitionKey($this->PARTITION_KEY);
    	if ($guestbook->getRowKey() == null) {
    		$guestbook->setRowKey(uniqid ());
    	}

	$tableStorageClient->insertEntity($this->TABLE_NAME, $guestbook);
    }
  }

As you look at that code, there’s a couple of things to point out.

  1. I could pass in parameters to the constructor of the Zend_Service_WindowsAzure_Storage_Table constructor to give my account information for a Windows Azure storage account but if you don’t pass anything in it defaults to the dev storage account.
  2. In the fetchAll() function,  the second parameter being passed to the retrieveEntities function is a filter parameter. This is where you could pass in the search parameters and/or a partition to retrieve and so on. Regardless of what you pass in, the function attempts to match on those items and returns a collection of items that match.

The next thing is to create the GuestBookController.php in the application\controllers folder.

<?php
/**
 * GuestbookController
 *
 * @author
 * @version
 */
require_once 'Zend/Controller/Action.php';
class GuestbookController extends Zend_Controller_Action
{
    /**
     * The default action - show the home page
     */
    public function indexAction ()
    {
        $guestbook = new Application_Model_GuestbookMapper();
        $this->view->entries = $guestbook->fetchAll();
    }

    public function signAction()
    {
        $request = $this->getRequest();
        $form    = new Application_Form_Guestbook();

        if ($this->getRequest()->isPost()) {
            if ($form->isValid($request->getPost())) {
                $comment = new Application_Model_Guestbook();
                $comment->comment = $form->getValue("comment");
	       $comment->email = $form->getValue("email");

	       $mapper  = new Application_Model_GuestbookMapper();
                $mapper->save($comment);
                return $this->_helper->redirector('index');
            }
        }

        $this->view->form = $form;
    }
}

Couple of things to point out here as well.

  1. In the indexAction, the fetchAll() call returns the list of entries as a collection and  hands it off to the view.
  2. In the signAction, we’re using the Application_Form_Guestbook which we are about to create. It’s got a little bit of validation but I wouldn’t rely on just that for my business logic but I’m a belt and suspenders kind of guy when it comes to data validation.

The next step is to create the Guestbook.php in application\forms directory.

<?php
class Application_Form_Guestbook extends Zend_Form
{
    public function init()
    {
        // Set the method for the display form to POST
        $this->setMethod('post');

        // Add an email element
        $this->addElement('text', 'email', array(
            'label'      => 'Your email address:',
            'required'   => true,
            'filters'    => array('StringTrim'),
            'validators' => array(
                'EmailAddress',
            )
        ));

        // Add the comment element
        $this->addElement('textarea', 'comment', array(
            'label'      => 'Please Comment:',
            'required'   => true,
            'validators' => array(
                array('validator' => 'StringLength', 'options' => array(0, 1000))
                )
        ));

        // Add a captcha
        $this->addElement('captcha', 'captcha', array(
            'label'      => 'Please enter the 5 letters displayed below:',
            'required'   => true,
            'captcha'    => array(
                'captcha' => 'Figlet',
                'wordLen' => 5,
                'timeout' => 300
            )
        ));

        // Add the submit button
        $this->addElement('submit', 'submit', array(
            'ignore'   => true,
            'label'    => 'Sign Guestbook',
        ));

        // And finally add some CSRF protection
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));
    }
}

The only thing to point out here is that this is a standard Zend Framework form.

The last thing that we absolutely need to do is create the two views, one for viewing and one for signing. The first one that we’ll create is index.phtml in application\views\scripts\Guestbook

<!-- application/views/scripts/guestbook/index.phtml -->

<p><a href="<?php echo $this->url(    array(        'controller' => 'guestbook',        'action'     => 'sign'    ),    'default',    true) ?>">Sign Our Guestbook</a></p>

Guestbook Entries (<?php echo count($this->entries) ?>): <br />
<table><tbody><?php foreach ($this->entries as $entry): ?> <tr>       <td><?php echo $this->escape($entry->email)?></td>       <td>
<?php echo $this->escape($entry->comment)?></td></tr><?php endforeach ?></tbody></table>

And next we’ll create the sign.phtml in application\views\scripts\Guestbook.

<?!-- application/views/scripts/guestbook/sign.phtml -->

Please use the form below to sign our guestbook!

<?php
$this->form->setAction($this->url());
echo $this->form;

There are other things that we could do but that all that we need to do for the moment. I’ll extend this example in the future.

Now, if you run the application and browse to http://localhost/simpleclouddemo/guestbook

If you get the error “Application errorexception ‘Zend_Http_Client_Adapter_Exception’ with message ‘Unable to Connect to tcp://127.0.0.1:10002. Error #10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.” – it’s because you need to launch the Development Fabric and specifically start the storage bit.

Once that’s done, you should see the guestbook as follows:

Empty

Then you can sign the guestbook as follows:

sign

And then it will redirect you back the guestbook which will look as follows:

firstentry

This is the bulk of what I demoed during the webinar. I’m going to continue to expand this demo as time goes on


Friday, October 15, 2010

imageI’m looking forward to starting this new webinar series that I’m launching in partnership with Zend about running PHP in general and Zend in particular on Microsoft Azure.

My goal, as I’m writing the demos today after posting this, is to go through the Zend Guestbook quick start and then port that to run in Azure and leverage that platform. I’ll be posting the full technical write-up here once I get done.

From the Zend web site:

Join a webinar on Cloud Computing with Zend Framework and Windows Azure. In this session, we’ll take a technical overview of Windows Azure Data Storage which can be used both inside and outside of your cloud application and the Windows Azure computing which can be leveraged to scale your application horizontally. We’ll write a small application with the Zend Framework and get it up and running in Azure so that we can dive deep into the individual parts in future webinars.
Join this webinar to learn how to take your application to the next level.

Register

It’s important to note that this is the first of a series so we’re going to do an overview across the board this time and then we’ll dive deep into things such as the data access layers or architecting for scaling horizontally across multiple instances in the future.


Items:   6 to 10 of 219   « Previous  | Next »