Join the MIX Conversation in Ireland!

clip_image001

Unplug from your day job. Be inspired at MIX.

Join the conversation at MIX – see the latest tools and technologies and draw inspiration from a professional community of your peers and experts.

MIX is a gathering of developers, designers, UX experts and business professionals creating the most innovative and profitable consumer sites on the web. The conference takes place in Las Vegas, but will be streamed live online http://live.visitmix.com. Join developer peers in Ireland on the hashtag #MIX11IE.

There’ll be great prizes on offer for both in-person & virtual attendees. Local evangelist www.twitter.com/joshholmes will be tweeting questions every 30 mins during the keynote (5pm-7pm) and answers should be emailed to endaf@microsoft.com. If you get all four answers right you are in the draw to win one of the following (we’ve cleared out our storeroom and here’s what we found J):

· Xbox Kinect bundle

· Arc Touch Mouse (x2)

· Xbox Live Gold Memberships 12 months (x3)

· Microsoft Web t-shirts (loads)

Questions to www.twitter.com/endaflynn

clip_image002

*competition open to residents of ROI and NI only

*entry to competition only possible before 7.30pm 12th April 2011

Windows Azure Toolkit for Windows Phone 7

WinPhoneAzureThe Windows Azure Toolkit for Windows Phone 7 is a starter kit that was recently released out to CodePlex. Wade Wegner, one of my former team mates when both of us were in Central Region, is the master mind behind this fantastic starter. 

This starter kit is designed to make it easier for you to build mobile applications that leverage cloud services running in Windows Azure.

Screencast

In the screencast, you’ll get a great little walkthrough of the starter kit and how to get your first Windows Phone 7 application with a Windows Azure backend up and running. The toolkit includes a bunch of stuff including Visual Studio project templates that will create the Windows Phone 7 and Windows Azure projects, class libraries optimized for use on the phone, sample applications and documentation.

Why Windows Azure

Windows Azure is Microsoft’s Platform as a Service (PaaS) offering that allows you to build and scale your application in the cloud so that you don’t have to build out your local infrastructure. If you are selling an application in the Windows Phone 7 Marketplace and really don’t know how many customers you’ll end up with, you might need to scale the backend dramatically to meet the demand. 

 

What you’ll need

Hopefully obviously you’ll need an Azure account and the tools to build and deploy the solution. The tools include one of the versions of Visual Studio (either Express which is free or higher), the Windows Azure Toolkit and then obviously the starter kit itself. I also recommend looking at Expression Blend for doing your Windows Phone 7 design and the like.

Good Luck!

By looking through the resources on the Windows Azure Toolkit for Windows Phone 7 site, you’ll see lots of great little tutorials and getting started guides.

Let me know how you’re getting on with the toolkit and what you’ve done with it. I’d like to see and possibly blog about it all…

Site Pinning in IE9

IE9Internet Explorer 9 (IE9) launched last week at SxSW! I was bummed that I wasn’t there but I was one of the 2.3 Million downloads in the first day. There’s a bunch of new stuff in IE9. There’s a load of examples out on http://www.beautyoftheweb.com that show off all of the new HTML5 support to javascript performance to a ton more.

A simple one, however is site pinning. This allows you to pin a website as if it were an application on the Windows 7 taskbar. This blending and merging of the web and desktop is awesome.

Now, you can pin any website to the taskbar and get generic results but you as a website author have control to actually do something cool and customize what that pinning does. You can customize the way your site is added to the taskbar as well as add your own jump list items.

MSApplication Meta Tags

The first place to get started is customize the application name, tooltip and frame with a few meta tags:

<meta name="application-name" content="Josh Holmes" />
<meta name="msapplication-tooltip" content="Random Thoughts" />
<meta name="msapplication-window" content="width=1024;height=768" />
<meta name="msapplication-navbutton-color" content="#ff7900" />
<meta name="msapplication-starturl" content="https://joshholmes.com/blog/" />

That’s simple. The next step is to add in a custom task that will let people dive deeper into the site with the right click:

<meta name="msapplication-task" 
content="name=View Articles;action-uri=./articles/;icon-uri=./favicon.ico" /> <meta name="msapplication-task"
content="name=About Josh;action-uri=./aboutme/;icon-uri=./favicon.ico" />

By default, IE9 looks for your 32×32 sized version of your favicon but if it can’t find one, it it uses your 16×16 one in a 32×32 box so you should use a high-res favicon if possible…

JavaScript

If your site is pinned, you can, if you want, do more that just sit there on the taskbar. You can interact with the jumplist and more.

Checking For Pinned Mode

First thing to know is if your site is actually pinned or not:

if (window.external.msIsSiteMode()) {
 // in pinned mode
} else {
 // not in pinned mode
}

 

Activating the Taskbar Icon

Let’s say that you need your user to interact with the application to keep session alive, or need them to complete a form or for some reason you need their attention back on the site, simple activate the taskbar icon by making it glow (Win7 Users are used to this UI paradigm):

window.external.msSiteModeActivate();

If making it glow is not enough but you have actual info for the user, such as if you are running a bulletin board service and want to let the user know that 3 new messages have arrived for them or something else random like that:

// clear current overlays
window.external.msSiteModeClearIconOverlay();
// set new one
window.external.msSiteModeSetIconOverlay("./newmessage3.ico", "3 new messages match your search");

Customizing the JumpList

And if you really want to customize the jumplist like with the last few articles that your user looked at, or the last few searches that they did or something more than the static setting of tasks that we did above:

// clear current jump list
window.external.msSiteModeClearJumplist();
// name the jump list
window.external.msSiteModeCreateJumplist("Adding JumpLists");
// add tasks to list – notice that these can have custom icons as well
window.external.msSiteModeAddJumpListItem("Item 1", "page1.html", "./favicon.ico");
window.external.msSiteModeAddJumpListItem("Item 1", "page2.html", "./favicon.ico");
// display list
window.external.msSiteModeShowJumplist();

JQuery Way

Of course, if all that’s too complicated or two much typing, you can just use the JQuery plugin – http://ie9ify.codeplex.com/. 😀

Conclusion

Hopefully this has been a short and sweet glance at some of the new site pinning features and the like.

ASP.NET/PHP on the Microsoft Web Platform Event in Ireland

Untitled

I’m really looking forward to moving to Ireland and I’m going to hit the ground running…

Right off the bat I’m going to be throwing an event called the “Evolution of ASP.NET and PHP on the Microsoft Web Platform”. One of the reasons that we’re throwing this event when we are is that we have Ryan Ozimek coming over to help me reprise and enhance the WebMatrix launch event.

Abstract: Web development is continually evolving on the Microsoft Web Platform. This evolution has brought fantastic new features and functionality such as the new Razor syntax and ASP.NET MVC 3 on the ASP.NET side and WinCache and FastCGI on the PHP side. And great new tools such as WebMatrix and the Web Platform Installer make it exceedingly simple to download, customize and deploy many of the top OSS applications, such as DotNetNuke for ASP.NET and Joomla! for PHP, on Windows.

image004Amongst the speakers at this developer evening are Josh Holmes, the brand new Architect Evangelist for Ireland, and Ryan Ozimek, president of Open Source Matters which is the non-profit that takes care of Joomla!.

Join us for an evening diving into how web development is evolving on the Microsoft Web Platform. We’ll start with an overview of the entire platform and the recent flood of announcements. Then we’ll dive deep into the individual topics of the new ASP.NET Razor syntax, ASP.NET MVC3 and PHP on Windows.
Whether you are doing ASP.NET or PHP, whether you have years of experience with web development or are just getting started you’ll find just the right flavour of web development for you.

Date: February 8th, 2011. 6.30pm-8.30pm (registration from 6pm)

image005Location:

The Westin Hotel

35 – 39 Westmoreland Street
Dublin 2
Map: Click here for a map

Please join us for this event by registering online.

The talks will wrap-up after two hours, giving attendees plenty of time to have a drink and some food whilst networking or playing around with some of the latest Microsoft gadgets.

image006

It’s Your Web, The WebMatrix (and more) Launch

I was thrilled an honored to deliver the WebMatrix Launch event at CodeMash this year.

First of all, CodeMash is a conference that I love. If you are not familiar with it, it’s one of the few conferences in the world where all technologies come together explicitly to share. The idea is that we are there to “Mash, not to bash”. I’m very proud of the fact that I was on the original board and was the emcee the first handful of years. In fact, it was at the first CodeMash that I originally shaved my head (well, technically Jennifer Marsman shaved my head… 🙂 ) But this “Mash, not to bash” concept make this the perfect place to launch WebMatrix but I’ll talk more about that in a bit.

Second, WebMatrix, Razor, ASP.NET MVC 3, all of the OSS contributions that Microsoft has been making and the whole keynote was a lot of very exciting news and technology that really remind me why I work at Microsoft!

Third, this is the first time ever that Microsoft has launched a product at a community event as well as the first time that a field Evangelist (me) delivered an launch event…

See the whole talk here:

It's Your Web - Josh HolmesNow, what did I get to talk about? The fun part is that this blog post is actually more detailed that I had time to get into myself during the talk. 🙂

The title of the talk is “It’s Your Web”. And this actually really well encapsulates the talk. During the course of the session, I’m really talking about how web development is evolving to work for you in the way that you want to work.

Simplicity is the ultimate sophistication500 years ago, Leonardo da Vinci said “Simplicity is the ultimate sophistication”. This is a saying that really lands with me. If you’ve seen any of my talks over the past couple of years, you’ll notice that simplicity is a reoccurring theme whether I’m talking specifically about it as in my “Lost Art of Simplicity” keynote that I’ve done a number of places or talking about UX or any of the other topics that I’m very passionate about.

As with Ice Cream

Everybody likes a different type of ice cream. Some people really like chocolate and nothing else will suffice. Other people like vanilla or strawberry. Personally I like Moose Tracks with the peanut cups and hunks of amazing fudge swirled into a creamy slice of goodness. but that may have to do with my obsession with Reece’s Peanut Butter Cups as the perfect candy.

Developing with ASP.NET, 3 flavors of web development

As with ice cream, everybody has a different flavor of web development. With ASP.NET, we’ve got 3 specific flavors that we will talk about today.

ASP.NET Web Pages are simple, light and fast. These are new and we’ll talk about them quite a bit today.

ASP.NET Web Forms are familiar, reusable and productive. These have been around for 10+ years, there’s a very mature control vendor market and the original design principle was to create a very productive environment for those new to web development.

ASP.NET MVC Framework is a very powerful,  extensible, robust and agile way to do development focusing on the architecture paradigm of Model View Controller.

Developer Tools

There are also different flavors of developer tools. Specifically, we are going to focus on WebMatrix and Visual Studio today.

WebMatrix is new and we’ll be talking about it a lot today as well. It’s a very simple toolset that supports both ASP.NET and PHP.

Visual Studio, our flagship developer product, is a very powerful, flexible and integrated toolset allowing you to go from architecture through the development/test phase and on into QA in the same toolset really managing the entire life cycle of a project.

Create, Customize, Publish

WebMatrix has been in beta for a little bit so you might have seen it. But in case you haven’t, WebMatrix, as stated before, is a simple tool that allows you to focus on the task at hand and solve problems. It’s designed to create, customize and publish web content very quickly and efficiently regardless of what type of web content that happens to be.  WebMatrix Web Stack

There are three major components with WebMatrix.

The first, and most visible is the Developer Tool. This is a stream lined IDE that supports both ASP.NET and PHP.

WebMatrix comes with a light weight, yet fully functional web server that doesn’t run as a service or require administrator rights to run. It may only be a 10mb download, but it’ll run ASP.NET as well as PHP, has full support for SSL, URL Rewriting and all the other IIS 7 modules whilst running on Windows XP and above.

WebMatrix also comes with a lightweight database that makes it quick to get started building websites. It’s file-based and only runs in-memory within your web application so when you shutdown your app, the database is automatically unloaded. Even better, with a download size of 2.5mb it installs with no configuration and works with existing data APIs and ORMs. When it comes to go to production you can use the database for lightweight scenarios or easily migrate to a SQL Server or SQL Azure with a simple change of the connection string. That said, you can, if you want to, use MySql or SQL Server with WebMatrix and it will work just fine.

WebMatrix ScenariosWebMatrix is designed around three basic scenarios. Sometimes you need to create something from scratch to solve a problem that’s specific to you or your organization. Of course you can use WebMatrix to do that.

Sometimes you have existing content that you need to organize, customize and publish and of course you can use WebMatrix to do that.

The third option, which is becoming more and more popular of an option is to start with an existing OSS application such as one of the many blog engines, CMS systems, eCommerce solutions and the like that are out there that will get you 80% of the way to solving your business need. With WebMatrix, you can pull a project down directly down from the Microsoft Web Application Gallery from within the IDE, customize and publish very quickly and efficiently.

Introducing RazorWith the introduction of WebMatrix, however, is not just a tool.

When you build a website with WebMatrix and choose the ASP.NET route, you’ll be using a brand-new coding syntax called Razor. Razor has been designed by the team to be quicker and easier to write code. You’ll notice that it allows you to flow from HTML markup to code seamlessly without having to define where the code starts and where it stops. The Razor parser does the hard work for you, allowing you to do more with fewer keystrokes.

As well as being the default syntax in WebMatrix, Razor is also the new way to code ASP.NET MVC 3. This shared syntax has a number of benefits including sharing code, migrations (which we’ll cover off a little later) and also Helpers.

Introducing Helpers

Let’s imagine that you want to sprinkle some social functionality into your website with Facebook or Twitter. It’s a common thing to do, so we wanted to make it as simple as possible for you. With Helpers it becomes a snap to do, with this code we render out a Facebook Like Button for a page.

Perhaps I want to add eCommerce payments to my website using PayPal. Well there’s a Helper for that too and we’ve taken care to make the API as simple as possible.

Now, I want you to notice that using a helper leverages the Razor syntax and looks exactly the same as accessing any of your own objects and methods.

Tons of helpers

But the helpers don’t just stop at social media or eCommerce.

In fact, there’s already a vibrant, open source community of helpers ready for developers to use. As well as social and payments with Facebook, PayPal and Twitter,

there’s helpers for forms, polls, Bit.ly as well as Razor templates that I can use in my websites.

What about if I want to get feedback for my website, or add documents from online libraries? There are helpers for that too.

If you want to add the latest Geolocation information or crowd sourced deals from Groupon, there’s Helpers to make that easier.

And if you can’t find exactly what you need, there are some great foundational helpers that will allow you to talk to any service that leverages OData or even store and consume data in the cloud with Windows Azure.

Building an app from scratch

And this is the point at which James Senior (great name) did a demo using WebMatrix to create a web site mostly from scratch.

He started off with a new project created from a template showing off the cool and fairly complete templates that come with WebMatrix. Then he leveraged the database manager built into the IDE to manage and edit the database. Once the database was squared away, he finished out the site levering the Razor syntax, a template from TemplateMonster.com and a PayPal helper.

Lastly, he showed how to publish directly from WebMatrix to a host.

Microsoft Web Application Gallery

But creating a site from scratch is not the only way to create a web site with WebMatrix. You can start with any of the close to 40 applications that are in the Microsoft Web Application Gallery to create your project. To date there have been more than 2.5 million downloads from the Microsoft Web Application Gallery. Some of these applications are ASP.NET, such as DotNetNuke, Umbraco and BlogEngine.net. Others are PHP such as WordPress, Joomla!, Drupal, MODx and Gallery.

Customizing DotNetNuke using WebMatrixI like showing better than telling so to show how awesome this workflow can be with WebMatrix, Shawn Walker and Joe Brinkman from DotNetNuke came onstage to demonstrate building a DotNetNuke site with WebMatrix. It was a great demo that showed off some great new functionality. They have some awesome new Razor based templates, can leverage SQL Server Compact Edition and more.

PHP and MySQL on Windows

But WebMatrix is not just for ASP.NET. It also supports PHP. Personally, I really like cross language tools like this. Microsoft’s investment in PHP over the past number of has been awesome and has made both PHP and MySql on Windows ready for prime time. IIS7, for example, has great support with FastCGI, WinCache, URL Rewrite and more. Create a Joomla! website with WebMatrix

At this point, I had the pleasure of bringing Ryan Ozimek on stage. Ryan is the president of Open Source Matters which is the non-profit organization that takes care of Joomla!. It’s amazing to me and it makes me very proud that Ryan was interested in getting up on stage during a Microsoft session and demo a Microsoft tool with Joomla!. It’s a testament to the investment we have make in PHP on the Windows stack, the PHP community and Joomla! in particular.

Ryan just slayed the demo too. It was awesome how easy it is to work with Joomla! with WebMatrix. He showed downloading, customizing and a ton more just like DotNetNuke. But another very useful thing is that he showed managing a MySql (which I know that I miss-pronounced on stage) with the WebMatrix database manager.

Announcing Microsoft WebMatrix RTM

When I took back the stage, I got to say, which I thought was awesome, that WebMatrix is released and you can download it right now from microsoft.com/web.

There’s multiple reasons that’s exciting. First and foremost, WebMatrix speaks to new audiences and fills gaps with existing audiences in a great way.

Second, this is the first time in history that Microsoft has launched a product at a community run event. There have been launches as VSLive and a couple of other pro-events that Microsoft is heavily involved with. But CodeMash is definitely an independent conference and the fact that we launched a product there is really a testament to the conference.

Third, as far as I know, I’m the first person to launch a Microsoft product that was not a member of the Microsoft executive ranks (VP/President/CXO…).

WebMatrix is available right now from microsoft.com/web and you can try it out for yourself. I’m really looking forward to hearing some from you about what you think of it and how you’re using it.

Many Flavors of Web Development

It was funny to talk to my brother-in-law, Tomas, on the weekend after the show. He runs IT for a school district in Kansas. He had downloaded and tried WebMatrix. I asked him if it was everything that I had promised that it would be. He said “Absolutely, I’ve already deployed two sites with it!”. His co-worker asked him, “Does this mean that I don’t have to buy Visual Studio anymore” and Thomas answered him “They are for very different purposes. WebMatrix does the simple things that were really hard to do in Visual Studio”. I was so proud of him. He got it.

WebMatrix is but one of the flavors of Web development that we talked about at during this event.

More Web Platform Updates

The Web Platform and Tools team have also been working hard on enhancements to our existing web stack.

We’ve added powerful features to ASP.NET MVC 3 like the new Razor syntax, Dependency Injection, Unobtrusive Ajax and jQuery Validation support, Global Action Filters and more.

With Visual Studio 2010 Service Pack One, the same web server that WebMatrix takes advantage of, IIS Express and SQL Server CE, is now included as a core part of your development environment.

Open Source ContributionsA subject that I’m very passionate about and have been thrilled to be involved with in some small part is that we’ve also been busy working on many open source projects too.

In March, Scott Gu announced that we were to begin contributions to jQuery, the world’s most popular JavaScript library. This past 10 months, we’ve contributed a new client-side templating engine, a data-linking plugin and a globalization plugin. These have been accepted as official plugins and the templating feature will be in a future version of the core jQuery library too.

In the past two months, we’ve also been working with the Outercurve foundation on a new open source package management system called NuGet. This project makes it easy to find and use the many open source .NET libraries out there. We’ve seen a massive movement around the NuGet project and there have been over 300 open source packages contributed.

And of course, we continue to drive the ASP.NET MVC project which is itself open source and has a vibrant community around it.

ASP.NET MVC 3 DemoThis was definitely the longest and most involved demo during the session. James Senior came back out to show a lot of great new things in ASP.NET MVC framework. I’m not going to drain the demo but some highlights included leveraging Nuget from Powershell right from within Visual Studio to grab packages that James needed for the demo, leveraging the Razor view engine, the slight and unobtrusive jQuery validation and more.

Announcing many web platform updatesAt the end of this demo, I had the great privilege of announcing that all of the technologies that we talked about are available right now for download at microsoft.com/web. That includes ASP.NET MVC Framework 3, IIS Express, SQL Server Compact, NuGet and Orchard.

We didn’t talk much about Orchard but that project dropped a 1.0 release on the same day as the WebMatrix launch.

Download your flavor of web development today...To recap, during the session you got to see a lot of different individual technologies in action but more importantly you saw how as a whole, from ASP.NET with ASP.NET web pages to ASP.NET MVC 3 to PHP, web development on the Microsoft Web Platform is evolving.

Go to microsoft.com/web to download your flavor of web development today.

You can watch it the presentation and all the demo online at http://channel9.msdn.com/Shows/Web+Camps+TV/CodeMash-2011-WebMatrix-Launch-Keynote.

Off to Ireland…

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!!!

Rev it up with PHP and IIS

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.

ASP.NET and PHP On IIS Together

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.

Zend SimpleCloud and Azure

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

Webinar on Oct 20, 2010 with Microsoft/Zend

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.