Friday, 6 June 2014

PHP 5.5 Builds

PHP 5.5

A little bit late but I've updated to PHP 5.5.  There are a few improvements that I like, and a great opcache extension, all covered in detail here so no need to go on about it:

New PHP extension builds

New builds of php_sqlsrv and php_spidermonkey are available including PHP 5.5 supporting 32 and 64 bits (64-bit builds are in the x64 folder of the zip file).

Friday, 7 September 2012

How to install Microsoft's SQL Server Driver for PHP

There are questions on Microsoft's SQL Server driver for PHP forum from people that cannot work out how to install the PHP driver.

PHP offers some help on choosing extensions here:, and here:

It's still a bit complicated, so here are some explicit instructions which I hope can help new users of PHP.  After a while all of this will become common sense.

Thursday, 12 July 2012

PHP_Wincache - Wincache for PHP 5.4

** Update May 2014 **
Don't use wincache on IIS 7+.  I found that PHP on IIS runs faster without wincache, and when wincache is used it always causes php to seize up after a large number of requests and your server will stop responding.  PHP 5.5 has a built in op-code cache extension, so it's probably not worth using wincache any more.

Microsoft's official release of Wincache 1.3 for PHP 5.4 and 5.5 is now available on the Wincache home page:


Wednesday, 13 June 2012

FindProxyForURL - Parse a PAC (proxy auto config) file in PHP

Proxy servers are used in most companies as a gateway to the internet, that do other things like cache results and check web requests and responses.  A PAC file is a Javascript file evaluated by web browsers to determine which proxy server to use for certain URL's.  For example, some URL's can go straight to the internet, or a local server, and others must be sent to one of the proxy servers.

One day I needed to run this javascript from php on the web server, to find the proxy in the same way; then php could also follow the same proxy rules as desktop computers in my office.

Here's a working example of using the php_spidermonkey extension to run a proxy auto config script (javascript) in PHP.

Javascript Return Statement

After 20+ years of programming I learnt something new today, while messing about with the php_spidermonkey extension.

If you place a carriage return after a 'return' statement in Javascript, and put some code on the line underneath, the function returns 'undefined', as if the statement was simply: return;

Here's an example of a function that returns 'undefined':
function whatelse()
    var ok = false;
    return // function ends here
        ok ? 'OK (true)' : 'OK (false)'; // this line is never executed!

Javascript in PHP on Windows with php_spidermonkey

Update 19 June 2014 - the latest builds of php_spidermonkey for Windows are contained in this zip:  I reported a few days ago that the PHP 5.5 TS build did not work - as of 19 June 2014 it works.  PHP 5.5 includes 64-bit versions in the x64 folder of the zip file.

I recently had a problem to solve: run some Javascript from inside PHP on a web server.

I needed to evaluate a web browser's PAC (proxy auto config) file exactly the way a browser would, by executing the Javascript function FindProxyForURL (see here for a good guide). The browser uses its Javascript engine, so to simulate it, I wanted to run Javascript inside PHP (an example is here in another post). 

Unofficial Microsoft SQL Server Driver for PHP (sqlsrv)

Here are unofficial modified builds of Microsoft's sqlsrv and pdo_sqlsrv drivers for PHP, version 3.0, for:

  • PHP 5.6 for Windows Vista/2008 and above (32 and 64 bit) 
  • PHP 5.5 for Windows Vista/2008 and above (32 and 64 bit) 
  • PHP 5.3 and 5.4 for Windows XP/2003 and above (32 bit)
    Microsoft's version 3.0 driver does not run on XP/2003 because it has a hard-coded dependency on the SQL Server 2012 Native Client (ODBC driver), which will not install on XP.  To fix the problem I just had to allow the PHP driver to use an older version of the ODBC driver supported by XP.