Work items collected from Tek-X

Last week I was in Chicago in the company of very passionate and smart PHP programmers at Tek-X. I got to meet some well-known members of PHP community and also fellow Microsoft employees who have been working on improving PHP experience of Windows. I would admit that meeting people was the best part of Tek-X for me. Sessions were great too and I learnt a great deal from them. I returned to Seattle more knowledgeable and passionate for PHP then ever. One of the things I wanted to get from Tek-X was a list of problems PHP users face on Windows so that we can work on solving them. Below is the list of work items I collected during informal discussions, questions during my talk and from other sessions.
 
1.       PHP 5.3 in WebPI
Today, Web Platform Installer (WebPI) only offers latest version of PHP 5.2. Folks want us to offer PHP 5.3 through WebPI. We receivedthis request during web developer summit and work for this is already in progress.
 
2.       PECL extensions in WebPI
There are few PECL extensions which are very popular (e.g. XDebug, uploadprogress) and people want us make them available in WebPI.
 
3.       WebPI to download PHP from windows.php.net
During my WebPI demo, Derick Rethans pointed out that we are downloading PHP from http://sourceforge and not http://windows.php.net. We used to install PHP from windows.php.net but moved recently to sourceforge when windows.php.net went down for maintenance. We will move back to windows.php.net once it has mirrors set.
 
4.       SQL driver for PHP extension on PECL
PHP community is very happy with the fact that WinCache source code is in PECL repository and documentation is exclusively available on php.net. They want SQL driver for PHP extension to move from codeplex to PECL. Even better will be moving related documentation from http://www.microsoft.com to http://www.php.net as well.
 
5.       PHP frameworks in WebPI
During my talk, people asked if there are any plans to add popular PHP frameworks like CakePHP and Zend Framework in WebPI. If a PHP application code already has framework code included, WebPI will just copy that as part of application install. Right now there are no plans to offer standalone PHP frameworks from WebPI. I will be discussing with the product team and see if this makes sense for us.
 
6.       Simplify setting up of PHP build environment on Windows
Many at Tek-X made fun of the fact that compiling PHP on Windows is incredibly hard. I have published a script (winbuild.bat) which makes this very easy. I will continue to produce documentation/scripts related to this unless building PHP on Windows is seen as a simple task.
 
7.       CHM file for PHP documentation script
Gennady told me that script which pulls in php.net documentation and creates a CHM file is broken and need some fixes. He loves access to php documentation even when offline and want the script to work. I will be looking at it and try to fix it.
 
8.       Pre-built PECL binaries for Windows
http://pecl4win.php.net has been down for ages. Many showed frustration with the fact that pre-built PECL binaries for Windows are hard to get. Pierre has few extensions built regularly and has them available for download here. Getting binary for an extension which is not available here is as easy as sending Pierre an email. If you want to build the PECL extension yourself, you can follow the instructions here. We still need to look into pecl4win.php.net or its replacement plans.
 
9.       Getting operating system information from PHP is hard
Elizabeth Marie Smith, in her awesome Cross Platform PHP talk, mentioned that getting system information on Windows is hard. I will be following up on this and make fixes to PHP as needed.
 
10.   Debugging dependency check errors is very hard
Elizabeth Marie Smith mentioned this in her talk. I will look into this and see what can be done.
 
I will be following up on each of these and hopefully will close on most of these requests before Tek-2011J. If this list doesn’t capture something you need for better php on Windows experience, please leave a comment and I will add it to this list.
 
Thanks,
Kanwal

Adding a PECL extension to your PHP build environment

Last week I published winbuild.bat to setup PHP build environment on windows. In this blog I am covering how to add a PECL extension to the PHP build system. I will also show how to static link a PHP extension and how much performance benefit you can get by that.
 
Building a PECL extension
 
Let’s say you have the PHP build environment set in the folder c:\php\php_sdk\php_53_dev\vc9\x86\PHP_5_3. For adding PECL extension (e.g. WinCache) to the build process, first download source code of the extension in c:\php\php_sdk\php_53_dev\vc9\x86\pecl\ folder. You can use the following commands to do this.
 
pushd c:\php\php_sdk\php_53_dev\vc9\x86\
md pecl\wincache
cd pecl\wincache
tortoiseproc /command:checkout /path:. /url:http://svn.php.net/repository/pecl/wincache/trunk/ /closeonend:1
popd
 
Once you have downloaded the source code, follow steps below to add the extension to your build process.
 
1.       Open visual studio command prompt and run c:\php\php_sdk\bin\phpsdk_setvars.bat to set PHP build window.
2.       Go to c:\php\php_sdk\php_53_dev\vc9\x86\PHP_5_3 andrun buildconf.bat. This will make PHP build environment to create configure.js again with option to build WinCache.
3.       Run “configure –help” to confirm that –enable-wincache option is now present in configure options.
4.       Open config.nice.bat and add “–enable-wincache=shared” option to the configure command.
5.       Run config.nice.bat to generate new makefile.
6.       Run “nmake snap” to build full PHP or just use “nmake php_wincache.dll” to build only WinCache extension.
 
Running “nmake” command will create php_wincache.dll under c:\php\php_sdk\php_53_dev\vc9\x86\PHP_5_3\release folder. Steps above add PECL extension wincache to the PHP build system. You can add any other PECL extension to the build system by replacing wincache with that extension name. You can add multiple extensions by adding multiple switches to your configure command.
 
Static linking and performance comparison
 
Above steps used “–enable-wincache=shared” option in the configure command to add wincache to the build system. “=shared” tells the system to link the extension dynamically. Removing “=shared” from “–enable-wincache” or for that matter any configure switch will make that extension link statically. Performance with static linking is significantly better than when extensions are dynamically linked. If you know what PHP extensions you use, you can create a custom build with all those extensions statically linked. Let’s see how much performance improvement we get by statically linking wincache compared to when wincache is dynamically linked. I am using wordpress as the sample application.
 

 

 
Throughput
Response time
Dynamic linking of wincache and mysql. All others as set by winbuild.bat.
68.05 requests/sec
726 ms
Static Linking of wincache and mysql extensions. All others as set by winbuild.bat.
72.12 requests/sec (5.98% better)
692 ms (4.68% better)
 
As you can see, just static linking of two extensions increased performance by ~5%. A custom build with needed PHP extensions statically linked will almost always perform better than official build from php.net. I hope that my last blog and this blog makes it easier to create custom PHP build on windows. I am experimenting with PGO builds these days and I will share my findings about that soon as well. Till then, CHAO.
 
Thanks.
Kanwal