Well.Done (c) Radek Hulán [EN]
Zend Server CE (PHP 5.3) with SQL Server driver

Zend Server CE (PHP 5.3) with SQL Server driver

18.09.2009

Running PHP applications on IIS is a very good idea especially since PHP 5.3 release, thanks to close cooperation between Microsoft and Zend, which brought us many Zend engine optimizations on Windows. PHP 5.3 can also (and finally) be compiled natively in Visual Studio 2008 or 2005, unlike old PHP releases which required Visual C++ 6.0 (released in 1998).

PHP on IIS is always using FastCGI interface, and should be combined with bytecode pre-compiler and code optimizer like Zend Optimizer+.  Zend Optimizer+ is part of PHP distribution from Zend, and is available free-of-charge as Zend Server Community Edition.

Running PHP on Windows also means you can use SQL Server 2008 database instead of (slow and unstable in my experience) MySQL.

Microsoft offers SQL Server Driver 1.1 for PHP on Codeplex, which is currently the best driver (considering both functionality and speed) to use for PHP <-> SQL Server 2008 communication.

There is one problem though. Zend Server CE is compiled using Visual Studio 2005 (VC8), while SQL Server Driver binaries are available only in VC6 or VC9. Unfortunately, VC9 extensions and VC8 PHP do not mix together. Fortunately, SQL Server driver source code is available on Codeplex, so you can easily compile it yourself.

Source code and compilation tools you need

How to compile

Download latest PHP 5.3 source code and unpack it into e.g. C:\inetpub\php.dev\. Also unpack Win32build and bindlib_w32 tools into subdirs. 

Download SQL Server driver for PHP source code and unpack it into ext\sqlsrv .

Now run Visual Studio 2005 Command Prompt, which will set-up all variables required for VC8 command-line compiler.

Next create "configure" by running buildconf.bat.

When compiling PHP, you can safely disable all extension, as they are already part of Zend Server CE, and build only sqlsrv extension. You should also disable thread-safe environment using --disable-zts, as FastCGI / IIS takes care of thread safety itself.

cscript /nologo configure.js --enable-sqlsrv=shared 
 --with-php-build="C:\inetpub\php.dev\win32build\bin" 
 --with-extra-includes="C:\inetpub\php.dev\bindlib_w32" 
 --without-gd --without-iconv --disable-calendar 
 --disable-com-dotnet --without-mysqlnd --disable-ctype 
 --disable-filter --disable-tokenizer --disable-bcmath 
 --disable-odbc --disable-phar --disable-json --disable-zip 
 --disable-session --disable-ftp --without-ereg 
 --disable-zlib --without-libxml --without-dom --without-xml 
 --without-simplexml --disable-zts  

Last step is to run nmake, which will compile those files.

Compilation result

Result of successful compilation will be PHP core files, which you don't need, and also file Release\php_sqlsrv.dll, which is our compiled SQL Server driver for PHP using Visual Studio 2005, and thus compatible with Zend Server CE / PHP 5.3.

PHP 5.3 compiled with VC8 is faster and more stable than previous 5.2 / VC6 releases, and together with IIS 7.5 and SQL Server 2008 they create robust platform for needs where simple LAMP does not suffice.

SQL Server Driver 1.1 kompilovaný s VC8SQL Server Driver 1.1 compiled with VC8

Download

If you do not want to go through the whole process, you can download compiled SQL Server Driver 1.1 for PHP VC8 binary in file php_sqlsrv.zip . For driver license, please see Codeplex.

21:07:22 - Friday, 18.09.09 - category: PHP - 31763x - permalink

Exports:

Exports: Print [print].

Comments:

  1. [1] Kokesh 82-117-125-194.tcdsl.calypso.net

    I guess that MySQL being unstable and slow is the mainreason for being most used DB on the internet:)

    reply to this comment votes: -1 10.10.2009, 11:41:54

Add new comment:

Spam control
New comment