CTP 2 of Microsoft Driver for PHP for SQL Server Released!

I was planning on writing up a long blog post about the CTP of the Microsoft Driver for PHP for SQL Server driver but Brian Swan already did a fantastic job complete with code. Quick snippet from his post:

Here’s a high-level list of the work that was done for this release:

  • Code refactored to share common functionality between the SQLSRV and PDO_SQLSRV drivers.
  • SQLSRV extension is rebuilt with refactored code (no new features).
  • PDO::__construct(): a design change from CTP1, Connection Options now need to be specified in the DSN string instead of the driver_options[] array.
  • PDO::SQLSRV_ATTR_DIRECT_QUERY: new custom driver attribute to provide more flexibility to the developer.
    • Ability to execute two queries within the same context or different contexts (useful for using temp tables and other features that are not always available with prepared statements).
  • Error messages are now encoded per the setting of CharacterSet / PDO::SQLSRV_ATTR_ENCODING.
  • Bug fixes to both the PHP_SQLSRV and PDO_SQLSRV extensions.

My thought on this is that it’s another great step in Microsoft’s working with the PHP community. A colleague actually asked “Am I right we are picking up the tempo in terms of PHP related activity?". I was able to answer with an enthusiastic “Yes”. 🙂

Make sure to check out Brian’ Swan’s Post at CTP 2 of Microsoft Driver for PHP for SQL Server Released.

Resolving PHP Version Conflicts while Developing for Azure

A little while back I wrote a blog post titled Easy Setup for PHP On Azure Development. One of the things that I touched on is the PHP version conflicts. I had a much better idea which I’ve tried and have working so I thought I’d blog that here. What I had you doing in the Easy Setup for PHP On Azure Development is renaming the directory for PHP from something like C:\PHP or C:\Program Files\PHP to something else so that it wasn’t in the %PATH% so there wasn’t a conflict.

The Fix

Reality is that we don’t have to do that. Instead, we can all co-exist happily on the same box. In short, what we’re going to do is load the local version of PHP from our box into the dev fabric rather than using the one that’s bundled with the Eclipse plug-in. The way that we’re going to do that is by using the web.config to specify the location on the local disk where our PHP install is.

That web.config looks something like this:

<?xml version="1.0"?>
<configuration>
  <system.webServer>
  
    <!-- DO NOT REMOVE: PHP FastCGI Module Handler -->
    <handlers>
      <clear />
      <add name="PHP via FastCGI"
           path="*.php"
           verb="*"
           modules="FastCgiModule"
           scriptProcessor="c:\program files\php\php-cgi.exe"
           resourceType="Unspecified" />
      <!--add name="PHP via FastCGI"
           path="*.php"
           verb="*"
           modules="FastCgiModule"
           scriptProcessor="%RoleRoot%\approot\php\php-cgi.exe"
           resourceType="Unspecified" /-->
      <add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
    </handlers>
    
    <!-- Example WebRole IIS 7 Configation -->
    <defaultDocument>
      <files>
        <clear />
        <add value="index.php" />
      </files>
    </defaultDocument>
    
  </system.webServer>
</configuration>

Notice that I’ve commented out the original handler that setup the processer with the %RoleRoot%\approot\… We’ll need that when we go live but for now, we’ll use the one that’s actually using the hard path on my local disk.

The exciting part about it is that we’ll be able to use our own version of PHP with all of the extensions that we normally use and configured exactly to taste.

Testing Local

The other exciting thing is that you can actually test any of your WebRole code against your local IIS rather than having to deploy it to the DevFabric every time you want to test. Deploying to the DevFabric takes time and so I’ve found myself taking more time and slinging just a little more code than I should before doing my testing. Against my local IIS box, I’m able to just refresh the browser and see instant results. I still definitely recommend running in the DevFabric because it’s as close to the real environment as you’re going to get at the moment.

image To test against your local IIS with the same exact source code and folders, simply set up the directory as a Virtual Directory. To do that, you need to do one of two things. You can open up the IIS manager and add it that way or you can use Powershell to do it.

In IIS manager, expand the navigation tree down to find the web site that you want to deploy your virtual directory on (typically this is “Default Web Site”) and right click. Then select Add Virtual Directory and fill out the wizard with the alias (e.g. myproject will end up with http://localhost/myproject) and the physical path that you want to use.

If you decide to go with the PowerShell option and do it from the command line, there’s a great cmdlet (Powershell script) called New-WebVirtualDirectory that you can leverage. Make sure that you read the instructions on how to Import All Modules.

The Catch

Now, the issue that you’ll have with this is that when you do actually go to deploy to the cloud, you’ll need to either retest with the version of PHP that’s bundled by default by the Eclipse tooling or make your deployment package by hand with the command line tools.

My recommendation is rolling your own package with the command line tools. Really all you need to do is use CSPack (and possibly CSRun to test locally) from my blog post at Windows Azure Command Line Tools.

Additionally, The great news there is that there’s some great tools available for you at http://azurephptools.codeplex.com/.

Wrap up

I’m much happier with this solution than I was with the whole renaming the directory hack. It worked but it was a pain when switching between regular and Azure development. This way, regular and Azure development are seamless.

WordPress Podcast

image

I was thrilled and honored to be a guest on the WordPress Podcast on WebMasterRadio.fm. This podcast is hosted by my friend Joost de Valk and Frederick Townes.

image I met Joost back at WordCamp Ireland back in March. That was a fun time. He and I talked about just about everything from being fathers to deep technical bits comparing various types of caching mechanisms. He even helped me with a number of SEO tips on my web site. Not sure if you’ve noticed but I’m turning up in a lot more searches thanks to him – he knows his stuff. Don’t believe me? Think just for a moment about how competitive this field is and then do a search for WordPress SEO in your favorite search engine and tell me what you think then… 😉

image I haven’t actually met Frederick yet but he comes with just a touch of credibility himself being the CTO of Mashable. He’s also the maintainer of the W3 Total Cache plugin. I’m a little jealous of him at the moment though as he’s been based in Florence, Italy for the past year or so… Must be rough.

One thing I will say though is that it’s becoming imperative that I get one of those spankin cartoon avatars.

The show was good but it *flew* by. Before I knew it, the WebMasterRadio dude was IMing us that we had 2 minutes left. All I could think about at points was that I hadn’t even mentioned the SEO toolkit, Windows Live Writer, URL Rewrite and a ton of other stuff that I wanted to get to. Oh well, we talked about a bunch of stuff. Maybe I can convince them there’s enough interesting content to do another show at some point.

So, what I did have time to talk about was a bunch of stuff. We started off with a little bit about me – (which is always a little embarrassing and I hate doing it but it is what it is).

Why the bleep is Microsoft doing this?!Joost started off by talking about how I ended up on the show in the first place. About a month ago, Zach Owens and some other guys from Redmond launched a site called http://wordpress.visitmix.com which talks about running WordPress on Windows and how great of an experience that can be. Not only that but there’s another micro-site that just went up at http://www.microsoft.com/web/wordpress. On both of these sites you can find links to the Web Platform Installer, the SQL Server plug-in for WordPress (in beta right now), plug-ins written by Microsoft for WordPress such as Windows Azure Storage for WordPress which allows us to store our files on Azure Storage for all of our media. 

I don’t know if you’ve noticed, but this site (JoshHolmes.com) is actually a WordPress blog as well. I switched over from dasBlog a few months back. dasBlog served me well but it was getting time to move on and WordPress was at the top of the list. Joost was actually the one that convinced me to migrate to WordPress. It didn’t take a tremendous amount of work to do it either. I used DasBlogML to suck out all of the content and then I imported it into WordPress, converted my theme over and was happy.

In addition to WordPress specific things stuff going on at Microsoft, there’s been a lot of support for PHP in general that has gone into IIS, SQL Server and many more of the Microsoft platforms. WinCache, for example, is a great caching tool for PHP on IIS. Just turning it on will result in a 3x or so improvement in performance in PHP on IIS. RuslanY has a great post on getting WinCache support into WordPress. And if you want to see how well it’s working, check out this module that shows you WinCache stats in WordPress. It was written by Kanwaljeet Singla who is the engineer behing FastCGI and WinCache. Cool stuff.

We also talked a little about JumpIn Camp and what happened there. phpBB getting into the Web Application Gallery and adding SQL Server support was one of the huge things that came out of that. 

image We also chatted about SQL Server a little. Frederick asked me about, to frame it in context for those that are not database or back end nuts, why this was important. It was a good question. In short, there’s a couple of really good reasons why someone would care. The first is that if one is at a company that already has SQL Server, it’s going to make a lot more sense to stand up your WordPress blog on SQL Server rather than introducing a new database engine and more administration to the existing infrastructure. A second great reason is that SQL Server has a ton of fantastic features that WordPress module authors could leverage such as Spatial Data or the fantastic analytics and reporting services that it offers. I teased Joost a little on the podcast about writing a module about that, but I think he knows as well as I do that I was serious as a heart attack that it would be an awesome set of modules. I’m hoping that Joost and others will take that challenge and run with it. If you do, let me know – I’ll be happy to help with whatever technical know-how that you need.

image Then we turned to PHP on Azure. This happens to be a passion of mine and I talk about it a lot… 🙂 I probably rambled a little on it talking about the differences between Infrastructure as a Service (IaaS) and Platform as a Service (PaaS) and what specifically Azure offers. If I was redoing the conversation, I would have cut a little on this conversation in favor of some of the things I didn’t mention such as URL rewrite… Oh well – I’ll do that here.

After that we went back to talking about the plug-ins that we found on http://www.microsoft.com/web/wordpress. There’s a handful of really good ones out there. One that struck Joost’s fancy is the Bing Maps plug in. Using WordPress short code and this plug in, it’s really simple to throw in a Bing Map on your blog.

Somewhere in here we were given the 2 minute warning.

All I had time left to talk about was the Toughest Developer Puzzle Ever.

I had a blast on the podcast and hope to be a repeat guest at some point. 

Toughest Developer Puzzle Ever

image For the second year in a row, my friend and colleague Jeff Blankenburg has created what is quickly proving to live up to it’s namesake – the Toughest Developer Puzzle Ever.

Some of the puzzles are technical, some are not but all require that you understand the web, development and technology to solve. Even if you don’t get in on the fantastic prizes that Jeff has lined up, there’s great bragging rights in being able to solve the Toughest Developer Puzzle Ever.

This year, I was honored enough to get to create three of the puzzles myself – let me know what you think of them. I’m not going to tell you which ones I created now and definitely don’t ask me for hints – Jeff has threatened me if I give any of the puzzle away… 😉

All I can say now is “Good luck!”