Working with Microsoft Silverlight on PHP

Working with Microsoft Silverlight on PHP

Rate This
  • Comments 3

Architecture diagram for an embedded Silverlight controlSilverlight Microsoft Silverlight, now at version 3.0, is a great way to create rich web applications that run on Windows, Mac OS and Linux. It provides an engaging, rich, safe, secure, and scalable cross-platform experience. Best of all you can run it off any web server (IIS, Apache for e.g.) and it can be called from any PHP website! Our team has released some helper samples to get you started. You can find the project on the Samples for PHP with Silverlight web page, and the project source can be found on Codeplex. The project includes sample HTML and PHP scripts.

How it works? Silverlight content is embedded into an HTML or PHP web page and in turn is transferred to the client browser where it is displayed by the Silverlight runtime (plugin) installed on the client computer. The architecture is shown on the right.

You will first create a Silverlight application file (.xap). We have provided a sample file, HelloPHPDevelopers.xap within the download or you can also create one for yourself by using another tech bridge we have, Eclipse Tools for Silverlight. Our colleague Steve Sfarz in France has a great post up on his site describing how to get started with it and create your own .xap file. This file is essentially a packaged archive or .zip file (try changing .xap to .zip and browse into it) with a collection of libraries that you have compiled for your application. If you follow the directions on the site you will end up with a button on a form with some custom actions.

You will then copy the .xap file you have created to a directory within your web site where you plan to host the Silverlight content. You will then want to create a custom HTML or PHP page that includes the following code in it’s body

image 

That’s all you need to run the .xap file you created and you can swap it out to any other file Silverlight application you choose to use.  If a user does not have the Silverlight plugin installed they will be presented with a 'Get Microsoft Silverlight' image and a link to install the plugin too. You should see an example of this in action right below this paragraph.

 

To do this dynamically from PHP, you can use the function below. This is handy if you have Silverlight content in more than one place on your website.

image

That’s all you need to take advantage of Silverlight as a content source for your PHP website. Have fun and share your experience back with us!

Jas Sandhu
Technical Evangelist, Interop Vendor Alliance Manager, Interoperability Strategy Team
Twitter@jassand, FriendFeed@jassand

Leave a Comment
  • Please add 6 and 1 and type the answer here:
  • Post
  • Loading...