Install Microsoft Drivers for PHP

Prerequisites

  • Apache Web Server
  • PHP 5.4, 5.5, or 5.6
  • These must be installed before starting (see figure ):
    • ○  SQL Server 2012 Express
    • ○  SQL Server 2012 R2 Native Client
    • ○  Microsoft Visual C++ 2010 SP1 Redistributable Package (x86)

control panel -> programs and features

The figure above is taken from the Control Panel -> Programs and Featurs For PHP 5.x, obtain drivers at:

https://www.microsoft.com/en-us/download/details.aspx?id=20098

Version support for PHP is as follows:

  1. Download SQLSRV32.EXE
  2. Unpack it to your desired directory. This directory needs to be one that will be accessible to theApache Web Server. In my case, I installed XAMPP, used the defaults, and my directory will be C: \xampp\php

Setting Up Web Tools Page 1

\xampp\php
a. You will notice several new files that are of the form:

PHP drivers for Microsoft
PHP drivers for Microsoft

i. Php_[pdo or sqlsrv]_5x.dll, where x is 4, 5 or 6 (see next figure)

3. Open your php.ini file

Note:  When you installed XAMPP, you got an XAMPP control panel.  Use it!   
For example, you can open the XAMPP control panel, on the Apache line, select CONFIG, and from the drop down menu you can easily open several config files, such as php.ini discussed in the next steps.
You can also define a default editor.  I like Notepad++ which is available at https://notepad-plus-plus.org/download/v7.html.
  1. Locate the extension_dir variable
php.ini file edit
php.ini file edit
  1. Locate the Windows Extensions section for your version of PHP
  2. Copy your dll’s into the folder given by the “extension_dir” of php.ini
  3. Add the following two lines (see next figure) extension=php_sqlsrv_5x_nts.dll extension=php_sqlsrv_5x_ts.dll

In this example, I have PHP 5.5, so my php.ini file looks like this:

screen-shot-2016-09-24-at-11-30-04-am

your php.ini file versions may be different.

4. Restart your Apache Web Server