Update For PHP 5.5

Apr 26, 2013 at 6:25 PM
Are there plans for this driver to be complied for PHP 5.5? If so, what is the timeline?
Jun 22, 2013 at 9:05 AM
+1 for that...
Jun 24, 2013 at 8:39 PM
+100 :)
Jun 24, 2013 at 8:51 PM
And as I guessed, no response....
Jun 24, 2013 at 8:53 PM
If we don't get a response soon, I will try to compile these myself. When I do, I'll update this post so that you can test my build if you want.
Jun 25, 2013 at 2:36 PM
Also msdn forum's php driver page has no responses to 5.5 driver needs.
So I've just downloaded VS 2012 Express + php-5.5.0-src + sqlsrvphp-src.
I try my best a couple of days...
Jun 25, 2013 at 3:22 PM
Ok, let me know.
Jun 26, 2013 at 9:39 AM
Edited Jun 26, 2013 at 9:47 AM
Ok, I compile for both normal and pdo drivers with Thread Safe (x86) / Non Thread Safe (x86).
I testes Non Thread Safe PDO driver with php 5.5 (x86) and it's working.
You can download files here:

Also I change file versions to 3.0.2 to solve confusion with the old versions.

This is a project of Microsoft Corporation and as the version.h file writes, I've permission to change the source code and distribute it with giving the details that I made and giving the copy of the license here: http://www.apache.org/licenses/LICENSE-2.0
Line 77 of php_sqlsrv.h changes from:
Jun 26, 2013 at 10:02 AM
Edited Jun 26, 2013 at 10:03 AM
Can you compile a 64bit version? Thank you.
Jun 26, 2013 at 10:18 AM
As http://windows.php.net/download/#x64 says, x64 is experimental and do not yet provide 64-bit integer support.
While I'm trying to compile for x64 I got integer errors and loss of data errors then compiler stops.
I think we must wait for real x64 support for php.
Jul 8, 2013 at 10:58 PM
I can confirm that it works on IIS 7.5 (Windows 7, x64), for PHP (php_sqlsrv_55_nts.dll.)
Jul 24, 2013 at 8:28 PM
I tried it and works fine for now. Thank you.
Jul 25, 2013 at 1:03 PM
I made an issue for this item, please go up vote it to bring attention to it for the project.

Jul 25, 2013 at 2:18 PM
Aug 26, 2013 at 3:44 AM
Hi Wshmstr,

Thank you very much bro. I have tested and can confirm that the Thread Safe versions work on PHP 5.5 on a x64 machine. My configuration is a WAMP and WASP stack with
Apache 2.4.4
MySQL 5.6.11
PHP 5.5.1
MS SQL 2008R2 (Express)
php_pdo_sqlsrv_55_ts.dll &
php_sqlsrv_55_ts.dll loaded as dynamic extensions. 
I haven't run performance tests yet, but I'm seeing a marked improvement in server performance for complex queries coded for earlier sqlsrv (again unofficial :-) drivers. I upgraded to PHP 5.5.1 yesterday thinking I'll compile the driver source and swallow the downtime. Boy! You saved me all that work.

And, this is precisely why I love open source. Regular Joes like me get assistance from awesome folks like yourself and if someday we get the chance; to pay it forward.

Once again, Thank you so much.

Life's complex, but the simple things are what matter most. I wish all of you the scent of a new idea and the liberty to pursue it.
Dec 24, 2013 at 7:20 PM
Take a look at Apachelounge, the Members download forum:

All my x86 builds contain a (unofficial) php_sqlsrv.dll. The latest for PHP 5.5.7 are in

Jan 26, 2014 at 12:54 PM
Version 5.6.0 alpha1 is online and we still don't have official support for version 5.5 :(
Jan 26, 2014 at 1:13 PM
Even worse: the sqlsrv extensions do not compile anymore under PHP 5.6.0alpha1, even after patching line 77 in php_sqlsrv.h.
Apr 17, 2014 at 1:16 PM
JanEhrhardt, very thanks!

I use xampp + php 5.5.11, and the dlls of sqlsrv in http://phpdev.toolsforresearch.com/php-5.5.7-Win32-VC11-x86.zip is working.
Apr 23, 2014 at 4:26 PM
I am trying to compile this in 64-bit but I keep getting this error:

LINK : fatal error LNK1181: cannot open input file 'x64\Release_TS\ext\pdo_sqlsrv\core_stmt.obj'

For pdo-sqlsrv and this:

LINK : fatal error LNK1181: cannot open input file 'x64\Release_TS\ext\sqlsrv\core_stmt.obj'

For sqlsrv, I checked the folder and none of those files exist or generated during nmake.

I'm using the latest sources from this website, how can I fix this?

Apr 23, 2014 at 4:55 PM
sqlsrv does not support x64 yet. If anyone knows a way I will be happy to add a php_sqlsrv.dll to
May 8, 2014 at 1:47 PM
Well, I have compiled sqlsrv for PHP 5.5 x86 just fine, but when I tried to compile it for PHP 5.6 x86 I still get the same error message, so it's not just x64, something else is happening with sqlsrv.

My compilations can be found at: http://www.fsbcomputers.com/extensions
May 13, 2014 at 6:56 AM
+1, please publish official release!!
Jun 10, 2014 at 2:27 AM
+1, please publish official release!!!
Jun 16, 2014 at 3:18 PM
+1, please publish official release!!!
Jun 19, 2014 at 8:07 AM
As of writing this PHP 5.6 is already in Beta 4, but still no official release of this driver for PHP 5.5, or any word thereof! I guess this project is dead...

Time to switch back to FreeTDS. At least the FreeTDS developers respond...
Jun 19, 2014 at 8:37 AM
Edited Jun 19, 2014 at 9:08 AM
They responded months ago that they said, they release official version, but nothing.
Probably they want to drop support. They don't want php & sql server community grow more and more because they also have a product (ASP.NET) which is only the competitor of php in the market. I've made few tests with odbc & native client, that I see native odbc is significantly faster then microsoft's pdo.
Only problem is sql injection, but I don't think that's a big problem. Internet full of functions & snippets about how to avoid sql injections while using odbc & sql server on php. Give a shot...

Edit: I'm giving you a very simple test results:

Scenario 1: A table with 1922 records inside it with simple SELECT and echo results. Both using SQL Server Native Client 11.0
Here are the results:

PDO: 0.16279983520508 s
ODBC: 0.076398849487305 s

ODBC is faster more than 2X.

Scenario 2: A table with more than 21 Million records inside it with simple SELECT TOP 100000 and echo results. Both using SQL Server Native Client 11.0
Here Are the Results:

PDO: 10.077439069748 s
ODBC: 3.9198169708252 s

ODBC is faster more than 2.5X

I already started to convert my codes to native ODBC. Not that hard.

Hope it helps...
Jun 19, 2014 at 10:29 AM
Edited Jun 19, 2014 at 10:34 AM
Thanks wshmstr.

Where did they (Microsoft?) respond? I'd love to see their message...

And what does it take to convert your code to ODBC? Surely you have to rewrite a whole lot of it?

Rewriting code is not an option for me. I'm using this SQLSRV driver to connect a system that I didn't develop (Moodle) to MSSQL - and it has over a million lines of code, so rewriting it is not an option.

But FreeTDS is! I have used it previously (before Microsoft released this SQLSRV driver) so reverting back it easy. And it has less bugs... I origionally switched to the SQLSRV driver from FreeTDS because using a driver from a big, professional, established, blah blah blah company like Microsoft gave me and my IT managers a warm secure fuzzy feeling. I guess I was wrong...
Jun 19, 2014 at 12:10 PM
MS actually replied back to the MS Connect issue a week ago.


Posted by Microsoft on 6/12/2014 at 11:09 PM
We are working on an updated version. We do not have final dates yet, but as soon as we close on the final dates, I'll update the community.

I'm also closing this issue as a duplicate due to infrastructure issues, so we can track it better.


Jun 19, 2014 at 12:17 PM
That's great news... although they said the same thing a year ago (2013/07/19 at 10:37 AM).

Looking forward to the release date...

Jul 31, 2014 at 2:56 AM
They'd better hurry. PHP 5.6.0 RC3 is out now.
Aug 1, 2014 at 5:33 AM
Microsoft are taking the piss. It took me less than two hours to built this stuff from a position of no knowledge. I just followed the instructions at https://wiki.php.net/internals/windows/stepbystepbuild. Now I have php_sqlsrv and php_pdo_sqlsrv for PHP 5.5 and I have it running perfectly on a couple of quite high-load sites.
Aug 1, 2014 at 9:41 AM
@PeeJ73: could you share your code somewhere? I regularly build PHP 5.3 - PHP 5.6 with a lot of extensions:
I would be happy to include php_sqlsrv.dll and php_pdo_sqlsrv.dll there in the 5.5 and 5.6 builds as well.
Aug 5, 2014 at 8:25 PM
@PeeJ73: did you compile php_sqlsrv.dll with Visual Studio 2008 (VC9) or with Visual Studio 2012 (VC11). It compiles with VC9, but all the other binaries of PHP 5.5 are compiled with VC11.
Aug 5, 2014 at 10:44 PM
I was building with VC11. I did another quick run through of the process this morning to create some notes for you and interestingly the php_pdo_sqlsrv builds without issue but now my php_sqlsrv fails with a missing reference. I will investigate this shortly but I can't help but feel I am missing something as I am sure this built without issues last time!
Aug 8, 2014 at 7:19 AM
OK. all sorted.:
  1. create a build tree for PHP 5.5.13 using the instructions at: https://wiki.php.net/internals/windows/stepbystepbuild.
  2. open the VS2012 Native Tools Command Prompt. Navigate to C:\php-sdk\phpdev\vc11\x86\php-source-directory.
  3. type 'buildconf'.
  4. type 'configure --disable-all --enable-sqlsrv=shared --enable-pdo --with-pdo-sqlsrv=shared --enable-cli'.
  5. type nmake.
Then, viola I have php_sqlsrv.dll and php_pdo_sqlsrv.dll in the C:\php-sdk\phpdev\vc11\x86\php-source-directory\Release_TS directory
Aug 10, 2014 at 1:38 PM
Thanks. What do you do differently to get the Non Thread Safe .dll for the NTS version of PHP?
Aug 10, 2014 at 1:53 PM
Compiling the .dll's is fine and if your PHP site runs fine then great...

The problem is that this makes IT Auditors in large corporate environments very jittery when they learn that the only way you could get a version of the .dll files for the current version of PHP that you want to run was by downloading the source code and compiling the .dll yourself using some unofficial build instructions that some kind person(s) published on the internet.

Before they are comfortable to allow new software on their servers they want it to be properly tested and those tests signed-off using proper testing and release methods and standards.

Who do they run to if those servers start experiencing performance issues when under high loads after those unofficial .dll's that you compiled yourself have been installed? Who do they go to for support?
Aug 10, 2014 at 9:55 PM
@Luisdev - all very interesting questions and, to be honest, I have no idea about NTS versions - I was just trying to help out with what I have. It is funny that you would feel better about the "support" offered by Microsoft on these DLLs when they have spent over a year "looking at it" and produced nothing. I also note that the vast majority of the worlds web servers run Apache and PHP with both generally being built from source - so what we are doing here is not that strange. I have no doubt Microsoft follows the same build instructions to make their version of these DLLs as they are as official as it gets. Or perhaps I should say - they would if they were actually trying to build the DLLs rather than just talking about it.
Aug 11, 2014 at 1:30 AM
cscript configure.js --disable-all --disable-zts --enable-sqlsrv=shared --enable-pdo --with-pdo-sqlsrv=shared --enable-cli
should do the trick for NTS
Aug 15, 2014 at 8:46 AM
@luisdev: your IT auditors will run into a problem then. PHP 5.6.0 will be released on August 28. From that day onwards PHP 5.4 will only get real security fixes only. And in August 2015 support for PHP 5.4 will stop completely. Given the pace the sqlsrv developers make at the moment, I will not be surprised to see that PHP 5.5 and 5.6 support won't be there in 2015.
Aug 28, 2014 at 1:20 PM
PHP 5.6 has now been released, and there's still no new official extension in sight. Where are you, Microsoft?
Aug 29, 2014 at 4:33 PM
I cannot believe the delay in this driver. With the release of 5.6 and the absence of any support for 5.5, despite having been released over a year ago, I am beginning to second guess my department strategy. We'd love to continue using PHP w/ SQL Server, but Microsoft is forcing us to reconsider this approach. Minimally, you could respond with a detailed update. Minimally...
Aug 29, 2014 at 9:49 PM

I fixed a compilation error and compiled Windows PHP 5.6 x86 NTS pdo_sqlsrv.dll and sqlsrv.dll
Aug 29, 2014 at 10:15 PM
Could you share your patch?
Aug 30, 2014 at 4:28 AM
I have a few builds and updated source code (with changes that I needed) to this driver:

JanEhrhardt: file "core_stream.php" around line 204, change function definition to this...
#if PHP_VERSION_ID >= 50600
static php_stream* sqlsrv_stream_opener( php_stream_wrapper* wrapper, const char*, const char* mode, 
                                         int options, char **, php_stream_context* STREAMS_DC TSRMLS_DC )
static php_stream* sqlsrv_stream_opener( php_stream_wrapper* wrapper, __in char*, __in char* mode, 
                                         int options, __in char **, php_stream_context* STREAMS_DC TSRMLS_DC )
This and the other changes are in the download.
Aug 30, 2014 at 3:24 PM
@robertjohnson: OK, I saw you fixed the 64-bit build as well. Kudos.
When building with your sources "the PHP way" I had to change version.h a little bit. The template.rc expects SQLVERSION_MAJOR etc and your version.h uses PROJECT_MAJOR etc. But otherwise building went fine. I have rebuilt my builds of PHP with a lot of extensions (uploading the x64 PHP 5.3/5.4 right now):
Inside the zip files is a phpinfo.htm with info about most of the extensions. For the sqlsrv extensions it displays this:

sqlsrv support => enabled
Version => (Unofficial)
Unofficial Changes => Works with Native Clients 11/10/9
Sep 1, 2014 at 9:28 AM
@JanEhrhardt - apologies for the error in version.h. thanks for the info.
Oct 10, 2014 at 5:53 PM
jfha73 - THANK YOU! My forehead is a mess from beating my head against the wall for weeks on this issue. Could not get WAMP to connect to SQL Server.
Oct 12, 2014 at 5:06 PM
Edited Oct 12, 2014 at 5:06 PM
Hi there,

PeeJ73 wrote:
OK. all sorted.:
  1. create a build tree for PHP 5.5.13 using the instructions at: https://wiki.php.net/internals/windows/stepbystepbuild.
  2. open the VS2012 Native Tools Command Prompt. Navigate to C:\php-sdk\phpdev\vc11\x86\php-source-directory.
  3. type 'buildconf'.
  4. type 'configure --disable-all --enable-sqlsrv=shared --enable-pdo --with-pdo-sqlsrv=shared --enable-cli'.
  5. type nmake.
I can compile the new PHP5.6 source code. But now I wanted to compile the sqlsrv driver for 5.6, when I execute the configure command, I got the following error:
C:\php-sdk\phpdev\vc11\x86\php-src>configure --disable-all --enable-sqlsrv=shared --enable-pdo --with-pdo-sqlsrv=shared --enable-cli
Unknown option --enable-sqlsrv; please try configure.js --help for a list of valid options
Any hint on how to fix this?

Many thanks
Oct 12, 2014 at 5:19 PM
Put the sqlsrv sources in C:\php-sdk\phpdev\vc11\x86\php-src\ext\sqlsrv and run buildconf in C:\php-sdk\phpdev\vc11\x86\php-src.
Oct 12, 2014 at 5:23 PM
JanEhrhardt wrote:
Put the sqlsrv sources in C:\php-sdk\phpdev\vc11\x86\php-src\ext\sqlsrv and run buildconf in C:\php-sdk\phpdev\vc11\x86\php-src.
Working perfectly!

Many thanks!
Nov 7, 2014 at 9:44 PM
Dec 19, 2014 at 8:08 AM
I recompiled my PHP 5.5 builds with the sources of MS and added x64 and PHP 5.6 support:

Changes to their sources:

Only the x64 php_pdo_sqlsrv.dll does not compile yet. Maybe someone here has an idea how to do that.

And could all of you test if my x32 and x64 builds work as expected...
Feb 26 at 6:48 AM
It seems that version 3.1 of the Microsoft Drivers for PHP for SQL Server was published on 12/12/2014 and is available on http://www.microsoft.com/en-us/download/details.aspx?id=20098. Thank you Microsoft...

One thing that bothered me though is the "Known issue" described at the end of the release.txt file included in the SQLSRV31.EXE package:

"3513544: Performance degradation when using Microsoft Drivers 3.1 for PHP for SQL Server with Windows 7/Windows Server 2008 R2 and previous versions. Clients connecting to supported versions of Microsoft SQL Server may notice decreased performance when opening and closing connections in a Windows 7/Windows Server 2008 R2 environment. The recommended course of action is to upgrade to Windows 8/Windows Server 2012 or later."

Has anybody experienced that "decreased performance when opening and closing connections" problem on Windows Server 2008 R2? If you have, how bad is it?

And are there any solutions - other than the "recommended course of action" ("upgrade to Windows 8/Windows Server 2012 or later")? In a corporate environment upgrading a OS isn't always a simple thing that you do in a few minutes. It can take weeks or months of planning and testing...