<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Juozas devBlog &#187; winphp</title>
	<atom:link href="http://dev.juokaz.com/tag/winphp/feed" rel="self" type="application/rss+xml" />
	<link>http://dev.juokaz.com</link>
	<description>Random ideas, scripts and facts</description>
	<lastBuildDate>Mon, 22 Mar 2010 10:48:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Finalizing WinPHP competition</title>
		<link>http://dev.juokaz.com/winphp-2009/finalizing-winphp-competition</link>
		<comments>http://dev.juokaz.com/winphp-2009/finalizing-winphp-competition#comments</comments>
		<pubDate>Mon, 01 Jun 2009 10:23:44 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[deepzoom]]></category>
		<category><![CDATA[jelly fish]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[rob allen]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[sql driver]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[winphp]]></category>
		<category><![CDATA[zfmssql]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=824</guid>
		<description><![CDATA[It&#8217;s been more than a month since this competition started, but the time ran very quickly. Today I&#8217;m going to summarize what I&#8217;ve used to create my entry and what I&#8217;ve learned.
Final application available at http://winphp.juokaz.com:82/.
Goal was:
My project will allow people to upload huge collections of photos (probably archived in one zip file) and get [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-830" style="margin-right: 5px; float: left;" title="Gallery" src="http://dev.juokaz.com/wp-content/uploads/2009/06/gallery.jpg" alt="Gallery" width="159" height="146" />It&#8217;s been more than a month since this competition started, but the time ran very quickly. Today I&#8217;m going to summarize what I&#8217;ve used to create my entry and what I&#8217;ve learned.</p>
<p>Final application available at <a href="http://winphp.juokaz.com:82/">http://winphp.juokaz.com:82/</a>.</p>
<p>Goal <a href="http://dev.juokaz.com/winphp-2009/first-annual-winphp-challenge">was</a>:</p>
<blockquote><p>My project will allow people to upload huge collections of photos (probably archived in one zip file) and get nice online gallery.</p></blockquote>
<p>I decided not to use archived files and simply allowed to upload multiple files using Silverlight <a href="http://www.codeplex.com/SilverlightFileUpld">control</a>, but pretty much everything left the same. My approach to this competition was to focus on technologies and not on functionality. That&#8217;s why I spent huge amount of time creating abstractions and making parts of application to be very customizable and not adding a lot of functions.</p>
<p>Functions in my app are really easy to add and in a matter of some lines one can add various parameters to images (tags, name etc.) and then sort/filter them &#8211; a lot of hard work is done under the hood. Silverlight based gallery is also absolutely independent from whole application and will work as long as front-end supplies correct gallery xml file, hence it can be easily customized. </p>
<p>Rules had 4 criterias:</p>
<ol>
<li> Application originality &#8211; I think I passed this one</li>
<li> Completeness &#8211; I have done everything what I&#8217;ve wanted</li>
<li> Use of Windows specific features/services &#8211; uses <a href="http://www.php.net/manual/en/book.com.php">COM</a> objects, Silverlight</li>
<li> Documentation of the process &#8211; <a href="http://dev.juokaz.com/category/winphp-2009">articles</a> in this blog and a lot of <a href="http://search.twitter.com/search?q=&#038;ands=&#038;phrase=&#038;ors=&#038;nots=&#038;tag=winphp&#038;lang=all&#038;from=juokaz&#038;to=&#038;ref=&#038;near=&#038;within=15&#038;units=mi&#038;since=&#038;until=&#038;rpp=15">tweets</a></li>
</ol>
<p>I think I have done everything that was required and now will try to push this application even further. Maybe Microsoft itself will show interest in it, because what I&#8217;ve done and used has been key topics in <a href="http://www.microsoft.com/events/mix/default.mspx">MIX 09</a>.</p>
<p><img class="alignnone size-full wp-image-826" title="Gallery x" src="http://dev.juokaz.com/wp-content/uploads/2009/06/gallery-x_1243856343122.png" alt="Gallery x" width="555" height="152" /></p>
<p><strong>Silverlight</strong> part and images processing is based on <a href="http://jellyfishdz.codeplex.com/">Jellyfish</a> library. At first I used <a href="http://dev.juokaz.com/winphp-2009/creating-deep-zoom-applications-with-c">Microsoft libraries</a>, but soon I got stuck because of lack of documentation and functionality. However Jellyfish is far from perfect &#8211; a lot of things are hardcoded, made <em>private</em> and hard to change. Also, it has some functions which are useful only in rare cases and need to be removed. For example, each mouse move, click and scroll used to look through all images in scene (using loop) and detect which one is under the mouse cursor. Very inefficient (especially if you don&#8217;t need it).</p>
<p><strong>Zend Framework</strong> was used to power whole website. I didn&#8217;t find any difference running it on Windows from running on Linux, so I can&#8217;t say much about <a href="http://dev.juokaz.com/winphp-2009/zend-framework-and-microsoft-iis">anything specific</a>. However, I <a href="http://dev.juokaz.com/winphp-2009/sql-native-client-as-mssql-driver-for-zend-framework">decided</a> to use the new <a href="http://sql2k5php.codeplex.com/">Sql driver</a> implementation for PHP, but it wasn&#8217;t included in Zend Framework supported adapters <a href="http://framework.zend.com/manual/en/zend.db.html#zend.db.adapter.adapter-notes">list</a>. That&#8217;s why me and <a href="http://akrabat.com/">Rob Allen</a> started a <a href="http://zfmssql.codeplex.com/">project</a> at <a href="http://www.codeplex.com">codeplex</a> to create an adapter for sql driver. It&#8217;s almost complete and at least both of us use it for our projects &#8211; everyone is free to test it and suggest changes though.</p>
<p><strong>Windows</strong> was good enough. I haven&#8217;t used Windows for any development for more than two years, but it worked surprisingly good. <a href="http://www.netbeans.org/">NetBeans</a> works the same in all platforms, but Visual Studio was almost a new thing. Nevertheless, both have done their job. <a href="http://www.iis.net/">IIS</a> was a <a href="http://dev.juokaz.com/winphp-2009/setting-up-windows-for-php-server">new thing</a> too, but I didn&#8217;t find a big difference for a developer, only that it allows to change everything without touching config files &#8211; I found it faster when settings are in multiple places.</p>
<p><strong>Community </strong>is outstanding. Stuart Herbert,  Rob Allen, Alton Crosslen and organizer Bram Veenhof were all chatting on <a href="http://search.twitter.com/search?q=winphp">Twitter</a> and it felt more like a community project and not a competition. Also the level of entries, from my point of view, is really high &#8211; this competition doesn&#8217;t had a lot of entrants (only slightly more than 10), but all of them are really competitive. </p>
<p>It was really a great time.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/finalizing-winphp-competition/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to use external libraries in PHP?</title>
		<link>http://dev.juokaz.com/winphp-2009/how-to-use-outside-libraries-in-php</link>
		<comments>http://dev.juokaz.com/winphp-2009/how-to-use-outside-libraries-in-php#comments</comments>
		<pubDate>Sat, 23 May 2009 14:24:58 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[com]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[deepzoom]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[gac]]></category>
		<category><![CDATA[gacutil]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php extensions]]></category>
		<category><![CDATA[regasm]]></category>
		<category><![CDATA[winphp]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=793</guid>
		<description><![CDATA[External libraries are useful for performance demanding tasks where PHP is simply too slow. Also PHP can work as front-end system for various back-end systems (where server doesn&#8217;t provide any PHP supported communication types). I have written some posts about using .Net libraries in PHP so far, but there are some other choices available too. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/osoft_1490922690php-logo-300x158.png" alt="osoft_1490922690php-logo" title="osoft_1490922690php-logo" width="150" height="79" class="alignnone size-medium wp-image-800" />External libraries are useful for performance demanding tasks where PHP is simply too slow. Also PHP can work as front-end system for various back-end systems (where server doesn&#8217;t provide any PHP supported communication types). I have written some posts about using <a href="http://dev.juokaz.com/winphp-2009/using-php-with-c-written-libraries">.Net libraries in PHP</a> so far, but there are some other choices available too. To start with, there are two main categories of possible external code usage in PHP:</p>
<ol>
<li><a href="http://pecl.php.net/">PHP extensions</a></li>
<li><a href="http://uk.php.net/manual/en/class.com.php">COM</a> objects, programs executed with exec()</li>
</ol>
<p>Today I&#8217;m going to look at all of them and explain my choice to use COM objects and not others from above. </p>
<h5>Three choices</h5>
<p><strong>PHP extensions</strong> (how to create them read <a href="http://devzone.zend.com/article/1021">here</a>) are fast and (at least should be) stable. However they are quite hard to create at start and uses <a href="http://en.wikipedia.org/wiki/C_programming_language">C</a>. For example, I&#8217;m now using library written in C# and rewriting it in C just to use it as extension is way to complicated and time consuming (and probably not worth it). I can only image PHP extensions as libraries to optimize some parts of code or to be used in multiple projects. In my <a href="http://dev.juokaz.com/winphp-2009/first-annual-winphp-challenge">case</a>, I only need to some limited tasks.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/visualstudio-6.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/visualstudio-6-150x150.png" alt="visualstudio-6" title="visualstudio-6" width="100" height="100" style="float: right; margin-left: 5px;" class="alignnone size-thumbnail wp-image-805" /></a>Next logical choice would be executing programs with <strong>exec()</strong>. In my opinion it&#8217;s the easiest way because programs can be created with any language you like, can be supplied with source code and none of system settings need be changed. If exec() is not blocked in php.ini it&#8217;s very practical solution. </p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/expolorer-1.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/expolorer-1-150x150.png" alt="expolorer-1" title="expolorer-1" width="100" height="100" style="float: right; margin-left: 5px;" class="alignnone size-thumbnail wp-image-807" /></a>Windows users has an option to use <strong>COM objects</strong>. COM objects stand somewhere between PHP extensions and exec(). They can be created in many languages, but libraries are not executed outside PHP script &#8211; they behave as normal PHP objects (almost). They are more convenient to work with than compiled programs, but need to registered with Windows.</p>
<h5>The best</h5>
<p>I was testing last two solutions for more than two weeks and my final choice is&#8230; COM objects.  To explain this choice here is a short story:</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/visualstudio-7.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/visualstudio-7-150x150.png" alt="visualstudio-7" title="visualstudio-7" width="100" style="float: right; margin-left: 5px;" height="100" class="alignnone size-thumbnail wp-image-809" /></a>I have a webpage which allows uploading multiple pictures. Two files are uploaded in parallel and once uploaded they are processed (resized, thumbnail and special structure for <a href="http://dev.juokaz.com/winphp-2009/creating-deep-zoom-applications-with-c">DeepZoom</a> is created). All this processing is written in C# and uses various windows and 3rd-party libraries.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/firefox-1.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/firefox-1-150x150.png" alt="firefox-1" title="firefox-1" width="100" height="100" style="float: right; margin-left: 5px;" class="alignnone size-thumbnail wp-image-803" /></a>At first I tried compiling a program as &#8220;console application&#8221; (in VisualStudio) and then run it with exec(). It worked as expected, but was a little bit too slow. Script was taking around 3 s. to execute, even though actual program ran in 1 s. I didn&#8217;t spent much time analyzing where overhead was coming from but it was clear that it can be optimized.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/iis-5.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/iis-5-150x150.png" alt="iis-5" title="iis-5" width="100" height="100" style="float: right; margin-left: 5px;" class="alignnone size-thumbnail wp-image-796" /></a>So I compiled program as &#8220;class library&#8221;, registered it with the <a href="http://en.wikipedia.org/wiki/Global_Assembly_Cache">Windows assembly cache</a> and then used with a <a href="http://uk.php.net/manual/en/class.dotnet.php">DOTNET</a> class. First problem was IIS server &#8211; it <a href="http://twitter.com/juokaz/status/1880755692">kept</a> throwing 500 errors no matter what I did. I didn&#8217;t wanted to waste my time trying to find where was a problem &#8211; after changing to COM class it magically started to work (even though it uses the same library). Using my library inside PHP was much more faster and execution time reduced to less than a second (depends on a size of image).</p>
<h5>Conclusion</h5>
<p>I have tested most of possible ways to execute external code. Even though COM objects perform better they can&#8217;t be suggested as default choice, because libraries need to registered with a system what can be problematic and maybe not even possible. So if you have limited permissions to server &#8211; use exec(), but in all other cases &#8211; I definitely recommend using COM. PHP extensions are even better, but harder to code and limited to C.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/how-to-use-outside-libraries-in-php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Passing data from PHP to Silverlight</title>
		<link>http://dev.juokaz.com/winphp-2009/passing-parameters-from-php-to-silverlight</link>
		<comments>http://dev.juokaz.com/winphp-2009/passing-parameters-from-php-to-silverlight#comments</comments>
		<pubDate>Fri, 15 May 2009 21:38:23 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[connect]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[params]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[winphp]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=745</guid>
		<description><![CDATA[Only on rare cases applications created with Silverlight (or Flash) are static &#8211; it&#8217;s very common to have information coming from a RSS feed, REST service or any other data source. What is more important, these applications usually needs configuration variables (user name, language, products category, etc.) to be passed to them. But how to [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://dev.juokaz.com/wp-content/uploads/2009/04/microsoft_silverlight_c-269x300.jpg" alt="Silverlight" title="Silverlight" width="90" height="100" class="alignnone size-medium wp-image-457" />Only on rare cases applications created with <a href="http://en.wikipedia.org/wiki/Silverlight">Silverlight</a> (or Flash) are static &#8211; it&#8217;s very common to have information coming from a RSS feed, <a href="http://en.wikipedia.org/wiki/REST">REST</a> service or any other data source. What is more important, these applications usually needs configuration variables (user name, language, products category, etc.) to be passed to them. But how to do all that?</p>
<h5>Configuration syntax</h5>
<p>Flash uses <a href="http://www.permadi.com/tutorial/flashVars/index.html"><em>flashvars</em></a> <em>object</em> parameter which is easy to use and passed variables automatically become available within actionscript variables scope. Luckily, Silverlight has almost the same thing.</p>
<p>Flash: <em>name1=value1<strong>&#038;</strong>name2=value2<strong>&#038;</strong>name3=value3</em><br />
Silverlight: <em>name1=value1<strong>,</strong>name2=value2<strong>,</strong>name3=value3</em></p>
<p>To start with, lets create a simple script which will form an arguments string (you can use <em>array</em> of params and then implode with &#8216;,&#8217;, but for the sake of simplicity I just use static string):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$connect</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/users/juozas'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Connect=&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">urlencode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$connect</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,id=1,somethingElse=true&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Inside an <em>object</em> element in HTML add this code (depending on framework you (not)use you may need to change it to work as a template or a view script):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;param name=&quot;initParams&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$args</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<h5>Reading configuration in Silverlight</h5>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-1.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-1-150x150.png" alt="silverlight-1" title="silverlight-1" style="float: right; margin-left: 5px;" width="100" height="95" class="alignnone size-thumbnail wp-image-762" /></a>If you start with a default Silverlight project in Visual Studio, you initially have two classes: App and Page. <em>App</em> is a main class, which (by default) on start up creates a new <em>Page</em> instance and assigns it to a root visual element of itself (<em>App</em>), where <em>Page</em> is your actual Silverlight application (visual part, controls, etc.). Standard start up event in <em>App</em> looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> Application_Startup<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, StartupEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">RootVisual</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>To use parameters from HTML tag, we need to get <em>initParams</em> from the passed <strong>e</strong> argument (which has type of <a href="http://msdn.microsoft.com/en-us/library/system.windows.startupeventargs.aspx">StartupEventArgs</a>) and set corresponding properties of some object to their values. You can have global static configuration class, but (also for simplicity) I just pass them to the <em>Page</em> instance:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> Application_Startup<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, StartupEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Page page <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">InitParams</span>.<span style="color: #0000FF;">Keys</span>.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Connect&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;&amp;</span> 
        <span style="color: #008000;">!</span><span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">InitParams</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Connect&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
     page.<span style="color: #0000FF;">connectPath</span> <span style="color: #008000;">=</span> HttpUtility.<span style="color: #0000FF;">UrlDecode</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">InitParams</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Connect&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">RootVisual</span> <span style="color: #008000;">=</span> page<span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Here I&#8217;m setting <em>connectPath</em> using <em>Connect</em> from <em>initParams</em>. One last thing &#8211; don&#8217;t trust user input, if you have integers, use <em>Int32.Parse()</em> and always check if passed values are in range of expected values. It&#8217;s really important to remember that SQL injections and other similar attacks are also threat in Silverlight (as Flash also).</p>
<h5>Outside information sources</h5>
<p>However, not all properties can be passed initially &#8211; some times it&#8217;s required to refresh information from server during actual runtime (think <a href="http://en.wikipedia.org/wiki/Ajax_(programming)">AJAX</a>). You can easily create asynchronous calls to server from Silverlight too (works almost exactly the same as normal JavaScript AJAX script):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> Page<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    InitializeComponent<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    LoadButton.<span style="color: #0000FF;">Click</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> RoutedEventHandler<span style="color: #000000;">&#40;</span>LoadButton_Click<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">void</span> LoadButton_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, RoutedEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    var wc <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> WebClient<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    wc.<span style="color: #0000FF;">OpenReadCompleted</span>
            <span style="color: #008000;">+=</span><span style="color: #008000;">new</span> OpenReadCompletedEventHandler<span style="color: #000000;">&#40;</span>wc_OpenReadCompleted<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    wc.<span style="color: #0000FF;">OpenReadAsync</span><span style="color: #000000;">&#40;</span> <span style="color: #008000;">new</span> Uri<span style="color: #000000;">&#40;</span> <span style="color: #666666;">&quot;/script.php?id=1&quot;</span>, UriKind.<span style="color: #0000FF;">Relative</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Text.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Loading...&quot;</span><span style="color: #008000;">;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0600FF;">void</span> wc_OpenReadCompleted<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, OpenReadCompletedEventArgs e<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span> e.<span style="color: #0000FF;">Error</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Do something with an error</span>
        Text.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> e.<span style="color: #0000FF;">Error</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0600FF;">else</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">try</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// e.Result has a type of Stream, so we need to read it first</span>
            <span style="color: #008080; font-style: italic;">// (not just cast to string)</span>
            StreamReader rdr <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StreamReader<span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Result</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Text.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> rdr.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">finally</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span> e.<span style="color: #0000FF;">Result</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #000000;">&#41;</span> e.<span style="color: #0000FF;">Result</span>.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-2.png"><img src="http://dev.juokaz.com/wp-content/uploads/2009/05/silverlight-2-150x150.png" alt="silverlight-2" title="silverlight-2" style="float: right; margin-left: 5px;" width="100" height="95" class="alignnone size-thumbnail wp-image-764" /></a>This code creates <em>onClick</em> event which asynchronously downloads &#8220;/script.php?id=1&#8243; and sets results to <em>TextBlock</em> element named &#8220;Text&#8221;. You can use absolute URLs too, but don&#8217;t forget that cross-domain requests protection will try to block it. Look <a href="http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx">here</a> to read more about how to avoid it. Not even localhost will work if you are testing with VisualStudio (witch creates temporary &#8220;ASP.NET development server&#8221; with random port (not 80)), so make sure to check it first. </p>
<p>As you can see it&#8217;s very easy and simple to create dynamical Silverlight applications. I have done some work with Flash too (probably more than with Silverlight, especially with <a href="http://en.wikipedia.org/wiki/ActionScript">ActionScript language</a>) and I can confirm that there isn&#8217;t much difference. Silverlight is more like <a href="http://en.wikipedia.org/wiki/Adobe_Flex">Flex</a> though.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/passing-parameters-from-php-to-silverlight/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic Assemblies loading using Reflection</title>
		<link>http://dev.juokaz.com/winphp-2009/dynamic-assemblies-loading-using-reflection</link>
		<comments>http://dev.juokaz.com/winphp-2009/dynamic-assemblies-loading-using-reflection#comments</comments>
		<pubDate>Fri, 24 Apr 2009 14:04:28 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[gac]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[reflection]]></category>
		<category><![CDATA[system.reflection]]></category>
		<category><![CDATA[winphp]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=544</guid>
		<description><![CDATA[Tuesday I&#8217;ve posted post how to use .Net assemblies in PHP, however, as Teal&#8217;c correctly pointed out:
Making your library COM visible requires that you register the DLL in the GAC and registering something in the GAC should only be done when multiple applications need to access the same version of the same library. Even then, [...]]]></description>
			<content:encoded><![CDATA[<p>Tuesday I&#8217;ve posted post how to use <a href="http://dev.juokaz.com/winphp-2009/using-php-with-c-written-libraries">.Net assemblies in PHP</a>, however, as Teal&#8217;c correctly pointed out:</p>
<blockquote><p><img src="http://dev.juokaz.com/wp-content/uploads/2009/04/picture.png" alt=".NET" title=".NET" width="48" height="48" class="alignnone size-full wp-image-566" style="float: right;" />Making your library COM visible requires that you register the DLL in the GAC and registering something in the GAC should only be done when multiple applications need to access the same version of the same library. Even then, most software houses will deploy each app with it’s own copy of the DLL instead of using the GAC.</p></blockquote>
<p>Nevertheless, C# (and most of other languages) support <a href="http://en.wikipedia.org/wiki/Reflection_(computer_science)">Reflection</a>. Basically using reflection, programs can &#8220;observe and modify its own structure and behavior&#8221; (wiki). .NET has <a href="http://msdn.microsoft.com/en-us/library/system.reflection.aspx">System.Reflection</a> namespace with all needed methods. Purpose of this post is to find a way how to load DLL&#8217;s dynamically &#8211; without worrying about registering, re-registering, unregistering them in running system/production servers. </p>
<p>DLL&#8217;s are library assemblies, which &#8220;contain code in CIL, which is usually generated from .NET languages, and then compiled into machine language at runtime by the CLR just-in-time compiler.&#8221; (<a href="http://en.wikipedia.org/wiki/.NET_assembly">from</a>). For all not familiar with assemblies, assembly &#8220;is a reusable, versionable, and self-describing building block of a common language runtime application.&#8221; (<a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx">from</a>). Consider this code:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Reflection</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Php
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Reflection
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">Object</span> get<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> assembly, <span style="color: #FF0000;">string</span> className<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Assembly asm <span style="color: #008000;">=</span> Assembly.<span style="color: #0000FF;">LoadFrom</span><span style="color: #000000;">&#40;</span>assembly<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> asm.<span style="color: #0000FF;">CreateInstance</span><span style="color: #000000;">&#40;</span>className, <span style="color: #0600FF;">true</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This is very basic class, which can be used to do such things as:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;">Php.<span style="color: #0000FF;">Reflection</span> obj <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Php.<span style="color: #0000FF;">Reflection</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #FF0000;">Object</span> my <span style="color: #008000;">=</span> obj.<span style="color: #0000FF;">get</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;my.dll&quot;</span>, <span style="color: #666666;">&quot;namespace.class&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>You may have thought that this class is absolutely useless, because you can simply use <a href="http://msdn.microsoft.com/en-us/library/system.reflection.assembly.aspx"><em>System.Reflection.Assembly</em></a> without wrapping it into separate class. However, I was writing this code with an intention to use it as <a href="http://uk2.php.net/manual/en/class.com.php">COM</a> object in PHP and because PHP can&#8217;t access static COM class methods (which I find very disappointing) I needed to create this class. Now in PHP you can write:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$obj</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Com <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Php.Reflection&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$math</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;math_class.dll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;phpclass3.first&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/dotnet_global_assembly_cache.gif"><img src="http://dev.juokaz.com/wp-content/uploads/2009/04/dotnet_global_assembly_cache-150x150.gif" alt="dotnet_global_assembly_cache" title="dotnet_global_assembly_cache" width="100" height="100" style="float: right; margin-left: 5px;" class="alignnone size-thumbnail wp-image-572" /></a>This method, in my opinion, is much much more better than registering every single class with <a href="http://en.wikipedia.org/wiki/Global_Assembly_Cache">global assembly cache</a>. It&#8217;s more practical and maintainable to have all required libraries in the same project directory, and not somewhere in Windows core. However, benchmarks are still coming so stay <a href="http://dev.juokaz.com/feed">tuned</a>.</p>
<p>* <em> For everyone interested in Winphp contest, and people building PHP apps in Windows, I recommend reading <a href="http://www.eurowinphp.com/">www.eurowinphp.com</a> blog, which aggregates all participants blogs. For example, Timmy Kokke, another WinPHP participant, recently wrote another great tutorial <a href="http://geekswithblogs.net/tkokke/archive/2009/04/24/how-to-use-.net-assemblies-in-php.aspx">how to make your .NET classes accessible in PHP</a>. Also, you can follow my on Twitter at <a href="http://twitter.com/juokaz">twitter.com/juokaz</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/dynamic-assemblies-loading-using-reflection/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP with C# written libraries</title>
		<link>http://dev.juokaz.com/winphp-2009/using-php-with-c-written-libraries</link>
		<comments>http://dev.juokaz.com/winphp-2009/using-php-with-c-written-libraries#comments</comments>
		<pubDate>Wed, 22 Apr 2009 14:59:48 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[challenge]]></category>
		<category><![CDATA[com]]></category>
		<category><![CDATA[comvisible]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows server]]></category>
		<category><![CDATA[windows xp]]></category>
		<category><![CDATA[winphp]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=509</guid>
		<description><![CDATA[One of the biggest issue for me in WinPHP challenge (more info) is using C# written libraries in PHP. Actual PHP part is very easy to write, because only thing you need to do is to create COM object. However, making your dll&#8217;s visible by PHP is a bit tricky. 
I followed this tutorial, which [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float:left; margin-right: 2px; " src="http://dev.juokaz.com/wp-content/uploads/2009/04/q2208984400_9262.jpg" alt="C#" title="C#" width="45" height="45" class="alignnone size-full wp-image-525" />One of the biggest issue for me in <a href="http://dev.juokaz.com/winphp-2009/first-annual-winphp-challenge">WinPHP challenge</a> (<a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge/Participants">more info</a>) is using C# written libraries in PHP. Actual PHP part is very easy to write, because only thing you need to do is to create <a href="http://uk2.php.net/manual/en/class.com.php">COM object</a>. However, making your <a href="http://en.wikipedia.org/wiki/Dynamic-link_library">dll</a>&#8217;s visible by PHP is a bit tricky. </p>
<p>I followed this <a href="http://www.devarticles.com/c/a/PHP/Using-the-.NET-Assembly-in-PHP/">tutorial</a>, which has most of required information. Firstly, you create your &#8220;Class library&#8221;, then create <a href="http://support.microsoft.com/kb/815808">assembly key file</a> and assign it to project assembly. After project is built, you register and add to global assembly cache your library. Probably it&#8217;s quite natural process for all .NET developers, but for PHP developer like me, registering something with whole system seemed quite odd (<a href="http://en.wikipedia.org/wiki/DLL_hell">dll hell?</a>).</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/visualstudio-1.jpg"><img class="alignnone size-thumbnail wp-image-510" title="visualstudio-1" style="float: right; margin-left: 5px;" src="http://dev.juokaz.com/wp-content/uploads/2009/04/visualstudio-1-150x150.jpg" alt="visualstudio-1" width="100" height="100" /></a>First problem was <strong><a href="http://msdn.microsoft.com/en-us/library/ms182157(VS.80).aspx">ComVisible</a></strong>. ComVisible is a keyword in assembly which is used to control types visibility: &#8220;If you need to access a type in this assembly from COM, set the ComVisible attribute to true on that type&#8221;. VisualStudio by default sets it to false, so all types are hidden and trying to register dll will result in this warning:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">RegAsm : warning RA0000 : No types were registered</pre></div></div>

<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/visualstudio-4.jpg"><img src="http://dev.juokaz.com/wp-content/uploads/2009/04/visualstudio-4-150x150.jpg" style="float: right; margin-left: 5px;" alt="visualstudio-4" title="visualstudio-4" width="100" height="100" class="alignnone size-thumbnail wp-image-533" /></a>Luckily, I find out about ComVisible property quite soon &#8211; it&#8217;s quite hard to know about it if you haven&#8217;t done anything serious with .NET. Nevertheless, after setting it to <em>true</em>, everything should work fine. Sometimes VisualStudio (2008 Professional Edition) refused to build project because of locked dll, so don&#8217;t forget to try to kill <a href="http://uk2.php.net/security.cgi-bin">PHP-CGI</a> process first (Ctrl+Alt+Del). I didn&#8217;t had any other problems.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/visualstudio-3.jpg"><img class="alignnone size-thumbnail wp-image-512" title="visualstudio-3" style="float: right; margin-left: 5px;"  src="http://dev.juokaz.com/wp-content/uploads/2009/04/visualstudio-3-150x150.jpg" alt="visualstudio-3" width="100" height="100" /></a>After some tests and failures I ended up with two simple C# classes and PHP caller. <em>Class1</em> has two public variables (<em>x</em>, <em>y</em>) which are set by PHP in <em>$math</em> object. Method <em>Class1.sum()</em> creates new <em>Math</em> object with constructor parameters <em>x</em> and <em>y</em>, and calls getSum() which returns sum of <em>x</em> and <em>y</em>. Useless stuff, but it worked great to test if:</p>
<ul>
<li>COM objects works</li>
<li>One class can call another (Class1 -> Math)</li>
<li>Types are correctly understood/converted</li>
</ul>
<p>Working PHP code (<em>phpclass2</em> is C# library namespace):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$math</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> COM <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;phpclass2.Class1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$math</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">x</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$math</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;sum = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$math</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$math</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Which successfully outputted:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">sum <span style="color: #339933;">=</span> <span style="color: #cc66cc;">200</span></pre></div></div>

<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/iis-1.jpg"><img class="alignnone size-thumbnail wp-image-511" title="iis-1" style="float: right; margin-left: 5px;" src="http://dev.juokaz.com/wp-content/uploads/2009/04/iis-1-150x150.jpg" alt="iis-1" width="100" height="95" /></a>I tried this code with the same <a href="http://www.microsoft.com/web/platform/default.aspx">Web Platform</a> I <a href="http://dev.juokaz.com/winphp-2009/setting-up-windows-for-php-server">used</a> in Windows Server 2008, but now with older IIS (v5, Windows XP) and it worked perfectly with all default settings. Also, IIS control panel in Server 2008 is 10 times better than in Windws Xp &#8211; in Xp-one I couldn&#8217;t even find how to add new virtual host (my bad, but in IIS 7 it&#8217;s way easier to do). And because I was installing it second time, it took me only few minutes.</p>
<p>Getting this to work was probably one of the biggest milestones &#8211; actual frontend code and <a href="http://msdn.microsoft.com/en-us/library/cc645050(VS.95).aspx">Deepzoom</a> C# library is not that tricky. After some days of working with PHP+Windows things are starting to get a shape &#8211; except of different OS GUI, web server works good in both Linux and Windows &#8211; clearly Microsoft is holding this competition to show it. And they are in the right way.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/using-php-with-c-written-libraries/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Setting up Windows for PHP server</title>
		<link>http://dev.juokaz.com/winphp-2009/setting-up-windows-for-php-server</link>
		<comments>http://dev.juokaz.com/winphp-2009/setting-up-windows-for-php-server#comments</comments>
		<pubDate>Tue, 21 Apr 2009 11:37:35 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[challenge]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[web platform]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[windows server]]></category>
		<category><![CDATA[winphp]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=469</guid>
		<description><![CDATA[To start with, all work took about 1:30, including Skype distractions, reading how-to&#8217;s, etc. Only one problem I had is that I was given remote desktop connection access to Windows Server 2008 machine, but I&#8217;m working with Linux. How to connect to remote desktop from Linux?
Luckily, I had Windows XP in VirtualBox so I tried [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-493" style="float: left; margin-right: 5px;" title="iis_logo" src="http://dev.juokaz.com/wp-content/uploads/2009/04/iis_logo.png" alt="iis_logo" width="160" height="76" />To start with, all work took about 1:30, including <a href="http://www.skype.com">Skype</a> distractions, reading how-to&#8217;s, etc. Only one problem I had is that I was given <a href="http://www.microsoft.com/windowsXp/using/mobility/getstarted/Remoteintro.mspx">remote desktop</a> connection access to Windows Server 2008 machine, but I&#8217;m working with Linux. How to connect to remote desktop from Linux?</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-15.png"><img class="alignnone size-thumbnail wp-image-488" style="float: right; margin-left: 5px;" title="screenshot-windows-xp-running-sun-xvm-virtualbox-15" src="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-15-150x150.png" alt="screenshot-windows-xp-running-sun-xvm-virtualbox-15" width="100" height="100" /></a>Luckily, I had Windows XP in <strong><a href="http://www.virtualbox.org/">VirtualBox</a></strong> so I tried it. And it worked really well. I&#8217;m using <a href="http://www.ed.ac.uk">university</a> internet network so connections speeds are very fast and Ubuntu -&gt; Windows Xp -&gt; Windows Server 2008 worked just fine. Later I will probably use real Windows system, but for first steps virtual machine worked much more faster than I expected.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-3.png"><img class="size-thumbnail wp-image-475" style="float: right; margin-left: 5px;" title="screenshot-windows-xp-running-sun-xvm-virtualbox-3" src="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-3-150x150.png" alt="screenshot-windows-xp-running-sun-xvm-virtualbox-3" width="100" height="99" /></a> Almost 4 years ago I had experience installing <strong><a href="http://en.wikipedia.org/wiki/Internet_Information_Services">IIS</a></strong> server, but I haven&#8217;t done much since then. Nevertheless, installing IIS+PHP was really easy &#8211; I followed <a href="http://blogs.msdn.com/bramveen/archive/2009/04/20/creating-your-php-dev-environment-for-the-winphp-challenge.aspx">this</a> tutorial, which shows you how to install <a href="http://www.microsoft.com/web/platform/default.aspx">Microsoft Web Platform</a>, and IIS was ready. Platform installer allows you to install not only SQL, PHP, ASP.NET, etc. but also various web applications &#8211; <a href="http://www.wordpress.org">Wordpress</a>, <a href="http://drupal.org/">Drupal</a> and many more. Experience with IIS was very similar to <a href="http://dev.juokaz.com/php/zend-server-complete-php-environment-in-minutes">Zend Server</a>, but IIS control panel is way better.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-8.png"><img class="size-thumbnail wp-image-478" style="float: right; margin-left: 5px;" title="screenshot-windows-xp-running-sun-xvm-virtualbox-8" src="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-8-150x150.png" alt="screenshot-windows-xp-running-sun-xvm-virtualbox-8" width="100" height="100" /></a>I chose to install Wordpress, just to test if IIS is working properly, but Platform installer doesn&#8217;t install <strong>MySQL</strong>. PHP is installed with MySQL extension, but no server is being installed &#8211; quite illogical. However, installing MySQL server is as easy as installing any other windows application (subjective) &#8211; download installer, Next, Next, Next and server is running. Also, <em>mysql</em> tool works the same in Windows <a href="http://en.wikipedia.org/wiki/Windows_command_line">cmd</a> and Linux console.</p>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-10.png"><img class="alignnone size-thumbnail wp-image-491" style="float: right; margin-left: 5px;" title="screenshot-windows-xp-running-sun-xvm-virtualbox-10" src="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-10-150x150.png" alt="screenshot-windows-xp-running-sun-xvm-virtualbox-10" width="100" height="100" /></a>Tutorials and other information:</p>
<ul>
<li> <a href="http://blogs.msdn.com/bramveen/archive/2009/04/20/creating-your-php-dev-environment-for-the-winphp-challenge.aspx">Creating your PHP dev environment for the WinPHP Challenge </a></li>
<li> <a href="http://www.microsoft.com/web/downloads/platform.aspx">Microsoft Web Platform</a></li>
<li><a href="http://learn.iis.net/page.aspx/610/setting-up-mysql-for-php-applications/">Setting up MySQL for PHP applications</a></li>
<li><a href="http://php.iis.net/">PHP on IIS7</a></li>
</ul>
<p><a href="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-14.png"><img class="alignnone size-thumbnail wp-image-485" style="float: right; margin-left: 5px;" title="screenshot-windows-xp-running-sun-xvm-virtualbox-14" src="http://dev.juokaz.com/wp-content/uploads/2009/04/screenshot-windows-xp-running-sun-xvm-virtualbox-14-150x150.png" alt="screenshot-windows-xp-running-sun-xvm-virtualbox-14" width="101" height="101" /></a><br />
What I liked very much is GUI for web server control.  Currently I have 13 web apps running in my laptop and every app has different port (localhost:80, localhost:81, localhost:82, etc.), but I haven&#8217;t found any good tool for adding more sites. I would like to have simple tool, which would accept port number and directory, and create virtual host. IIS control application allows it very easily.</p>
<p>In conclusion, working with PHP in Windows server seems to be pretty acceptable. I haven&#8217;t tested setting up anything except Wordpress, but Wordpress seems to work just fine. Especially I liked using GUI, because most of tasks for development machine can be done much more easier and faster, still I&#8217;m not going to switch from Linux yet.</p>
<p><strong>Advantages</strong>:</p>
<ul>
<li>GUI</li>
<li>Easy to setup</li>
<li>PHP works</li>
</ul>
<p><strong>Disadvantages</strong>:</p>
<ul>
<li>Some functionality is hard to find</li>
<li>Differences from Apache (<a href="http://www.petefreitag.com/item/286.cfm">mod_rewrite</a>, etc.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/setting-up-windows-for-php-server/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>First Annual WinPHP Challenge</title>
		<link>http://dev.juokaz.com/winphp-2009/first-annual-winphp-challenge</link>
		<comments>http://dev.juokaz.com/winphp-2009/first-annual-winphp-challenge#comments</comments>
		<pubDate>Mon, 20 Apr 2009 15:21:09 +0000</pubDate>
		<dc:creator>Juozas</dc:creator>
				<category><![CDATA[WinPhp 2009]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[competition]]></category>
		<category><![CDATA[deep zoom]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[silverlight]]></category>
		<category><![CDATA[winphp]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://dev.juokaz.com/?p=452</guid>
		<description><![CDATA[Sometime in the end of March Microsoft and partners announced 2009 WinPHP competition. I always wanted to try to create an app with both PHP and C#, so I decided to register &#8211; my idea is to create a project, which will demonstrate both PHP and .NET connectivity and Deep Zoom functionality.
My project will allow [...]]]></description>
			<content:encoded><![CDATA[<p>Sometime in the end of March Microsoft and partners <a href="http://blogs.msdn.com/bramveen/archive/2009/03/23/european-winphp-challange.aspx">announced</a> 2009 <a href="http://wiki.phpconference.nl/2009_WinPHP_Challenge">WinPHP</a> competition. I always wanted to try to create an app with both PHP and C#, so I decided to register &#8211; my idea is to create a project, which will demonstrate both PHP and .NET <a href="http://www.php.net/manual/en/ref.dotnet.php">connectivity</a> and <a href="http://msdn.microsoft.com/en-us/library/cc645050(VS.95).aspx">Deep Zoom</a> functionality.</p>
<p><img class="alignnone size-full wp-image-457" style="float: right;" title="Silverlight" src="http://dev.juokaz.com/wp-content/uploads/2009/04/microsoft_silverlight_c.jpg" alt="Silverlight" width="97" height="109" />My project will allow people to upload huge collections of photos (probably archived in one zip file) and get nice online gallery. Users will have selection of Ajax or <a href="http://silverlight.net/themes/silverlight/common/home.aspx?AspxAutoDetectCookieSupport=1">Silverlight</a> version and password protection for galleries. If I have time, I will also add ability to select different photos shuffle style, background theme and/or music, and maybe even automatic tour with captions.</p>
<p><img class="alignnone size-full wp-image-460" style="float: left;" title="Zend framework" src="http://dev.juokaz.com/wp-content/uploads/2009/04/logo-zend-framework.jpg" alt="Zend framework" width="120" height="80" />PHP will work as front-end language (with <a href="http://framework.zend.com/">Zend Framework</a>), and C# will be responsible for all Deep Zoom work (which I haven&#8217;t tried/tested yet, but I believe it will work). Not only it&#8217;s quite useful app, but also showcases a lot of cool technologies. <a href="http://www.leaseweb.com/en/">Leaseweb</a>, sponsor of this competition, provided us with dedicated servers so I will hopefully publish <em>alpha</em> version in some weeks.</p>
<p>Why I chose to participate? Firstly, it&#8217;s good experience, because I do a lot of <a href="http://dev.juokaz.com/category/php">PHP</a>, but also more and more <a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)">C#</a>, so it&#8217;s great opportunity to learn more. Secondly, in my belief, such competitions are really useful for portfolios and CV&#8217;s &#8211; I&#8217;m currently looking for a <a href="http://www.zend.com/en/store/education/certification/yellow-pages.php#show-ClientCandidateID=ZEND008553">job</a>, so it can help. Lastly, competitions are fun, so, I&#8217;m in.</p>
<p>Part of competition requirements is &#8220;<span lang="EN-US">blog about your experiences with Windows Server 2008 during the contest&#8221; so I&#8217;ll write around 2-3 posts every week about project status, problems with switching from Linux back to Windows and more. Also, I&#8217;m really bad in designing websites, so if anyone would like to help me &#8211; please feel free to contact. </span></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.juokaz.com/winphp-2009/first-annual-winphp-challenge/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
