Screencast: How To Deploy PHP Websites To Azure -- Without Visual Studio

April 18 2011

Here's a screencast that elucidates my step-by-step post on how to deploy PHP to Windows Azure:

How To Do PHP Deployment To Windows Azure

April 18 2011

You have a PHP application that targets PHP 5.3. You want to deploy it to Windows Azure. You do not have Visual Studio.  How do you do it?

Step 1 – Download The Windows Azure SDK (9 MB).

Step 2 – Download this .zip folder which will serve as the shell directory structure for your files. Unzip it.  It looks like this:

/root
  /AppFolder
    /bin
    /assets
    /putmoduleshere

Step 3 – Copy/Paste your web directory into the /AppFolder directory.  This would include all your .php, .html, .jpg and all other assets for the website. Do not delete any of the sub directories that exist in the AppFolder directory, such as the /bin folder or the /assets folder.  Also, do not delete the web.config that is in the /AppFolder directory.

Step 4 – Run the PackageCloud.cmd from the /root directory. This will create a file called ServiceDefinition.cspkg in the /root. 

Step 5 – Log in to http://windows.azure.com. Create a New Hosted Service.  When asked to chose a package, browse to the ServiceDefinition.cspkg that you created in Step 4.  When asked to upload a Configuration file,  ServiceConfig.cscfg which can also be found in the /root directory.

That’s it!  Note that the ServiceConfig.cscfg creates two instances of your site.  You can change your instances by changing the number established in that file, which is an xml file.

You can see the what default modules are supported by PHP on Azure looking at this page, which is a website I deployed to Azure using this very package. If you have php modules that you need deployed that aren’t here, you’ll need to add them to the /putmoduleshere directory and redeploy.  Note: I haven’t tested this, so I can’t guarantee it will work. If you do use this methodology to add PHP modules to Azure, leave a comment on this blog and report back your findings.

If you need to update any of the files for you website, you will need to copy those new files into the AppFolder directory and repeat steps 3 – 5.

Thanks to David Aiken and SyntaxC4’s post for helping to figure this out.  Both of these guys are Azure rockstars.

Foursquare Playground

April 12 2011

I’ve had the good pleasure of working with Foursquare in conjunction with Vectorform and the IE9 folks to unveil new features of the Foursquare Playground. Using CSS3 wizardry, geo-location in the browser, SVG and some serious Javascript jujitsu -- not to mention mad design chops -- Foursquare Playground shows off what is possible using nothing but web standards, serving to manifest a novel and illuminating view on the exponentially growing Foursquare dataset of realtime spatial gameplay.

Check out some screenshots:

1

2

KEXP Archive in IE9 Launch and Mellow Johnny's at SxSW

March 21 2011

KEXP Archive is a very cool HTML5 application that uses the KEXP dataset to show off a cool visualization. The KEXP data set represents nearly 10 years of radio playlists and includes over 700,000 tracks with album art, the date and time each song was played, and DJ names. The result, created by Stimulant, can be seen at http://kexparchive.org. Pretty rad.

This application was featured in the IE9 launch at SxSW -- watch it demonstrated in a video here.  Also, it was shown while KEXP broadcasted live from SxSW at Mellow Johnny's, Lance Armstrong's bike shop. Here's some pics of the KEXP IE9 kiosk in the bike shop:

 

 

 

Ze Frank and Star.Me at IE9 Launch

March 17 2011

Check out Ze Frank’s presentation at the IE9 launch event at SxSW:

 

Bruce Sterling at SxSW Interactive March 15 2011

March 16 2011

Was looking forward to hearing Bruce and he didn’t disappoint. He was cogent and pithy as ever.  Ultimately he wove together a theme about political agency in an era that has neutered it.

Here’s my notes:

  • Started out saying this was the best SxSW ever. Anti-nostalgia, no backlash on corporate sponsorship at the show, ultimately recognizing the core is intact and the gathering is solid
  • Talked about “design fiction”
  • Then switched to politics. Called out that political language has been decimated at present, reduced to “polarizing brand management.”
  • Called for “passionate virtuosity” – something artists have, can we strive for that across the board
  • First political topic was Synthetic Biology and J. Craig Venter.  Sterling was at presidential council of bio-ethics, not impressed with DC bureaucrats’ ability to parse the gravity of the technology.  Called out change in cultural discussion from genetic engineering debates of 70s and current lack of discussion about the technology. Exxon Mobil funding Venter. Sterling’s point was not anti-synthetic biology per se, but rather why are the corporations controlling the outcome instead of the people? No difference between industry and government in this day and age.
  • Switched to Italian politics and Italian Prime Minister Silvio Berlusconi’s involvement in sex scandal. A moral discussion.  And he brought it back to the states ultimately – Washington DC “a Walmart of a brothel.”  Kept using the term “calamitous.”
  • Concluded with “Who are the victims of a decaying status quo? The young people.”  Ripped on boomers for awhile – “get out of the way boomers” and called for “millenials” to start global youth movement.  Called for an end to the “era of organized deception.”  Instead of poem, quoted Girabelli’s call to battle, also “Women – do not embrace a coward.”
  • Final line: “Another world is inevitable; the future is unwritten.”

Curiosities in Microsoft.Web.Helpers: Video.Flash and Analytics.GetGoogleHtml

February 3 2011

Been digging into some of the classes in Microsoft.Web.Helpers. Lots of interesting things there, the basics being classes that inject scripts and HTML into your website for lots of popular activities and services out there. Many that you would expect (Bing, XBox gamer tag, File Upload)   A few surprises as well -- classes for Google Analytics, Recaptcha (a Google service) and a  Flash video player. Some screenshots: 

 

Kinda trippy but kinda great too. 

JSON Deserialization Made Simple With System.Web.Helpers and List<dynamic>

February 3 2011

Been playing with WebMatrix and have come across some crazy and beautiful code that I really liked in the FourSquare helper on CodePlex. Check this method out, which returns a graph of friends from the fourquare api

/// Returns a list of friends
    /// </summary>
    /// <param name="accessToken">The access token of the authenticating user.</param>
    /// <param name="userId">The Id of the person for whom to pull a friend graph. if not specified, the authenticating user's list of friends will be returned.</param>
    public static IList<dynamic> GetFriends(string accessToken, int userId = 0) {
        var url = "https://api.foursquare.com/v2/users/{0}/friends?oauth_token={1}";

        var client = new WebClient();
        var jsonResult = client.DownloadString(string.Format(url, userId == 0 ? "self" : userId.ToString(), accessToken));
        var result = Json.Decode(jsonResult);
        
        return new List<dynamic>(result.response.friends.items);
    }

Notice how tight this code is. And note the crazy dynamic typing that C#4 provides in combination with the Json.Decode method. If you are wondering where that JSON.Decode method came from, it is from System.Web.Helpers -- you can use this dll anywhere, doesn't have to be with WebMatrix or Razor. Here's a link to the docs on System.Web.Helpers.Json: http://msdn.microsoft.com/en-us/library/system.web.helpers.json(VS.99).aspx 

 Serialization and JSON have long been painful in .NET because of .NET's strong typing.  This got better with the C# dynamic keyword (see this post and this post) but nothing is as elegant as the code above.

Check this example out, which returns a user's FourSquare badges:

/// <summary>
    /// Returns badges for a given user.
    /// </summary>
    /// <param name="accessToken">The access token of the authenticating user</param>
    /// <param name="userId">The Id of the user</param>
    public static IList<dynamic> GetBadges(string accessToken, int userId = 0) {
        var url = "https://api.foursquare.com/v2/users/{0}/badges?oauth_token={1}";
        
        var client = new WebClient();
        var jsonResult = client.DownloadString(string.Format(url, userId == 0 ? "self" : userId.ToString(), accessToken));
        var result = Json.Decode(jsonResult);
        
        var badges = new List<dynamic>();
var groups = new List<dynamic>(result.response.sets.groups); var allBadgesGroup = groups.FirstOrDefault(g => g.type == "all"); if (allBadgesGroup != null) { foreach(var badgeId in allBadgesGroup.items) { badges.Add(result.response.badges[badgeId]); } } return badges; }

Notice how the two dynamic lists get created which are then manipulated with a LINQ lambda query.  Nice! Having dealt so often with either manually mapping JSON to CLR objects and/or dealing with arrays nested in arrays nested in arrays, I'm absolutely loving this.

 

YouTube Flips Switch On IFrame as Default Embed Code

February 2 2011
Interesting to see that YouTube has made their embed code default to an iFrame instead of using an <object> tag to insert a Flash player. This capability was introduced this summer, but it was more experimental then and only became the default experience last week.
The main motivation for the switch?  So that if you are on an HTML5 browser, you won't be sent Flash, but rather your browser will use the <video> tag and serve up either WebM or H.264.  Read more here.
What's interesting is that HTML5 on YouTube's site was an experiment, but with making their embed code an IFrame by default, it means HTML5 video becomes much more prevalent.The average Joe user who wants to embed a video on his blog will now be serving up HTML5 whether he realizes it or not.

BinPress Programming Contest: $40,000 in prizes

January 25 2011

I have the honor of being a judge in the recently announced BinPress Contest. As they say on their site:

Have you been developing custom solutions for the web? pick your best feature, module or UI component that can be packaged and re-used and publish it on Binpress. Binpress is a marketplace for source-code, where developers can sell and buy source code from each other.

If you've been writing reusable components or libraries, consider submitting. What have you got to lose?

VSAchievements
Visual Studio Achievements
Karsten Januszewski (207 Points)