Php 7 failed to initialize sqlsrv

I searched all day to find a solution for sqlsrv dll on php 7 VC14 x64 Thread Safe, and I did not find a solution. Has anyone solved this problem:

[04-Oct-2015 19:48:05 UTC] PHP Warning: PHP Startup: pdo_sqlsrv: Unable to initialize module Module compiled with module API=20131226 PHP compiled with module API=20141001 These options need to match in Unknown on line 0 

Here is my information on RC4 to RC4:

 System Windows NT 6.0 build 6002 (Windows Server 2008 Standard Edition Service Pack 2) AMD64 Build Date Sep 29 2015 17:15:28 Compiler MSVC14 (Visual C++ 2015) Architecture x64 
+7
dll php-7 php-ini sqlsrv
source share
3 answers

sqlsrv is not ready for PHP7 yet, but it is not. It has not been released since 2012. The latest version is from May 2015. Maintainer is Microsoft, and a version for PHP7 is scheduled for early next year.

https://github.com/Azure/msphpsql/issues/58

Update:

The driver is available for PHP up to version 7.1 even for Linux today (March 2017).

https://github.com/Microsoft/msphpsql

+12
source share

For future reference (tested on Windows 7 with Xampp and PHP 7.0.13):

enter image description here

  1. Place the DLL files in the Zip archive in the extension directory. Be sure to select the appropriate version. Note At first I tried using the x64 version, but that did not work. Then I replaced the DLL with the x86 version and finally worked.

enter image description here

  1. Returning to the "php.ini" file, you need to add the following line: "extension = php_pdo_sqlsrv_7_ts.dll". Note Xampp uses a safe version of the tread.

enter image description here

  1. Be sure to restart the apache service.

enter image description here

Sample code for testing:

 $db = "the name of your database" $password = "password"; $server = "IP address or named pipe"; $user = "username" try { $connection = new PDO( "sqlsrv:Server=" . $server . ";Database=" . $db, $password, $user ); $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $exception) { var_dump($exception); } 
+4
source share

For recording, a direct link to sql server libraries is here

sqlsrvr for php 7

Is version 32 and 64 bit for ts and nts

+1
source share

All Articles