Modified README files and removed odbc requirement to build

This commit is contained in:
Jenny Tam 2017-08-16 13:04:26 -07:00
parent 6f14e0f6d9
commit eda3b7f358
3 changed files with 78 additions and 59 deletions

View file

@ -42,33 +42,9 @@ Please visit the [blog][blog] for more announcements.
## Build (Windows)
Note: if you prefer, you can use the pre-compiled binary found [HERE](https://github.com/Microsoft/msphpsql/releases)
If you prefer, you can use the pre-compiled binaries found [HERE](https://github.com/Microsoft/msphpsql/releases)
#### Prerequisites
You must first be able to build PHP 7 without including these extensions. For help with doing this, see the [official PHP website][phpbuild] for building your own PHP on Windows.
#### Compile the drivers
1. Download the source code directory from this repository
2. Make a copy of *shared* folder as a subfolder in *sqlsrv* and/or *pdo_sqlsrv* folder
3. Copy the *sqlsrv* and/or *pdo_sqlsrv* folder into the PHP source ext subdirectory.
4. Run `buildconf --force` to rebuild the configure.js script to include the driver.
5. Run `configure.bat --with-odbcver=0x0380 and the desired driver options (as below) [plus other options such as --disable-zts for the Non Thread Safe build]` to generate the makefile. You can run `configure.bat --help` to see what other options are available.
* For SQLSRV use: `--enable-sqlsrv=shared`
* For PDO_SQLSRV use: `--enable-pdo --with-pdo-sqlsrv=shared`
6. Run `nmake`. Optionally, you can run `nmake clean` first.
7. To install the resulting build, run `nmake install` or just copy php_sqlsrv.dll and/or php_pdo_sqlsrv.dll to your PHP extension directory.
The extensions have been compiled and tested with the PHP 7.0.* and 7.1.* using the Visual C++ 2015 compiler as well as PHP 7.2.0 beta using the Visual C++ 2017 V15.0.
For an example of how to automate building the Microsoft Drivers for PHP for SQL Server, please browse the *buildscripts* directory.
The *buildscripts* directory contains step by step instructions on how to build the Microsoft Drivers for PHP for SQL Server. You can either build manually or use the sample scripts provided, which help automate the process.
## Install (Windows)
@ -86,7 +62,7 @@ For an example of how to automate building the Microsoft Drivers for PHP for SQL
3. Restart the Web server.
## Install (UNIX)
The following instructions assume a clean environment and show how to install PHP 7.x, Microsoft ODBC driver, apache, and Microsoft PHP drivers on Ubuntu 15, 16, RedHat 7, Debian 8, and Mac OS X.
The following instructions assume a clean environment and show how to install PHP 7.x, Microsoft ODBC driver, apache, and Microsoft PHP drivers on Ubuntu 15, 16, RedHat 7, Debian 8, and Mac OS.
### Step 1: Install PHP7+
@ -126,7 +102,7 @@ The following instructions assume a clean environment and show how to install PH
apt-get update
apt-get install -y php7.0 php-pear php7.0-dev php7.0-xml
**Mac OS X**
**Mac OS**
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap
@ -169,7 +145,7 @@ Note that there are no PHP 7.1 packages available for Ubuntu 15.10.
apt-get update
apt-get install -y php7.1 php-pear php7.1-dev php7.1-xml
**Mac OS X**
**Mac OS**
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap
@ -236,7 +212,7 @@ Note that there are no PHP 7.1 packages available for Ubuntu 15.10.
sudo ACCEPT_EULA=Y apt-get install msodbcsql
sudo apt-get install unixodbc-dev
**Mac OS X**
**Mac OS**
brew tap microsoft/msodbcsql https://github.com/Microsoft/homebrew-mssql-release
brew update
@ -280,7 +256,7 @@ On all systems, run:
echo "extension=sqlsrv.so" > /etc/php.d/sqlsrv.ini
echo "extension=pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini
**Mac OS X**
**Mac OS**
(echo "<FilesMatch .php$>"; echo "SetHandler application/x-httpd-php"; echo "</FilesMatch>";) >> /usr/local/etc/apache2/2.4/httpd.conf
@ -303,7 +279,7 @@ On all systems, run:
echo "extension=sqlsrv.so" > /etc/php.d/sqlsrv.ini
echo "extension=pdo_sqlsrv.so" > /etc/php.d/pdo_sqlsrv.ini
**Mac OS X**
**Mac OS**
(echo "<FilesMatch .php$>"; echo "SetHandler application/x-httpd-php"; echo "</FilesMatch>";) >> /usr/local/etc/apache2/2.4/httpd.conf
@ -322,7 +298,7 @@ Note: On RedHat, SELinux is installed by default and runs in Enforcing mode. To
sudo setsebool -P httpd_can_network_connect_db 1
**Mac OS X**
**Mac OS**
sudo apachectl restart

View file

@ -1,53 +1,96 @@
## Windows
# Windows
### Prerequisites
To use the Python build scripts `builddrivers.py` and `buildtools.py`, install Python 3.x.
## Prerequisites
To build extensions for PHP 7.0* or 7.1*, install Visual Studio 2015 and make sure C++ tools are enabled.
To build extensions for
* PHP 7.0* or PHP 7.1*, install Visual Studio 2015 and make sure C++ tools are enabled.
* PHP 7.2*, install Visual Studio 2017, including Visual C++ toolset, the Windows SDK components, and Git for Windows.
For PHP 7.2*, install Visual Studio 2017, and make sure Visual C++ toolset, the Windows SDK components, and Git for Windows are installed.
To use the sample build scripts `builddrivers.py` and `buildtools.py`, install Python 3.x in Windows.
See [PHP SDK page](https://github.com/OSTC/php-sdk-binary-tools) for more details.
## Compile the drivers
### Build PHP extensions
You must first be able to build PHP 7.* without including these extensions. For help with doing this, see the [official PHP website](https://wiki.php.net/internals/windows/stepbystepbuild) for building PHP 7.0* or PHP 7.1* on Windows or [PHP SDK page](https://github.com/OSTC/php-sdk-binary-tools) for the new instructions for building PHP 7.2 and/or above.
Launch a regular `cmd` prompt and change to the directory where these Python scripts are.
The Microsoft Drivers for PHP for SQL Server have been compiled and tested with PHP 7.0.* and 7.1.* using the Visual C++ 2015 as well as PHP 7.2.0 beta using the Visual C++ 2017 v15.0.
You'll be asked to input the PHP version. Simply type the version number like `7.1.7`.
### Manually building from source
If it's alpha, beta, or RC, make sure the name you provide matches the PHP tag name without the prefix `php-`. For example, for PHP 7.2 beta 2, the tag name is `php-7.2.0beta2`, so you should enter `7.2.0beta2`. Visit https://github.com/php/php-src to find the appropriate tag names.
1. Download the *source* directory from this repository
**Use Interactive mode**
2. Make a copy of the *shared* folder as a subfolder in *sqlsrv* and/or *pdo_sqlsrv* folder
Run `py builddrivers.py`
3. Copy the *sqlsrv* and/or *pdo_sqlsrv* folder(s) into the PHP source ext subdirectory
Most questions are self-explanatory. Use lower cases for your inputs, and you can simply hit `ENTER` key for `yes/no` questions.
4. Run `buildconf --force` to rebuild the configure.js script to include the *sqlsrv* and/or *pdo_sqlsrv* driver(s).
When given a choice whether to download from a GitHub repository, you can choose to provide the full path to your local Source folder instead.
5. Run `configure.bat` with the desired driver options (as shown below) to generate the makefile. You can run `configure.bat --help` to see what other options are available. For example, for non-thread safe build, add this option `--disable-zts`.
* For SQLSRV add: `--enable-sqlsrv=shared`
* For PDO_SQLSRV add: `--enable-pdo --with-pdo-sqlsrv=shared`
**Use Command-line arguments**
6. Run `nmake`. Optionally, you can run `nmake clean` first.
Run `py builddrivers.py` with command line arguments. For example:
7. To install the drivers, there are two ways:
* Run `nmake install`, or
* Copy the drivers:
* Find the directory where the newly compiled `php.exe` is
* Locate the compiled php_sqlsrv.dll and/or php_pdo_sqlsrv.dll
* Copy the dll(s) to the `ext` subfolder
`py builddrivers.py -v=7.1.7 -a=x86 -t=ts -d=all -g=no`
### Using the sample build scripts
or
The sample build scripts, `builddrivers.py` and `buildtools.py`, are expected to build our extensions for PHP in Windows.
`py builddrivers.py --PHPVER=7.0.22 --ARCH=x64 --THREAD=nts --DRIVER=sqlsrv --GITHUB=yes`
#### Overview
**Notes**
When asked to provide the PHP version, you should enter values like `7.1.7`. If it's alpha, beta, or RC, make sure the name you provide matches the PHP tag name without the prefix `php-`. For example, for PHP 7.2 beta 2, the tag name is `php-7.2.0beta2`, so you should enter `7.2.0beta2`. Visit [PHP SRC]( https://github.com/php/php-src) to find the appropriate tag names.
It's recommended that the PHP SDK is unzipped into the shortest possible path, preferrably somewhere near the root drive. Therefore, this script will create a `php-sdk` folder in C:\ drive. This `php-sdk` folder will remain unless you remove it yourself. For ongoing development, it's suggested you keep it around. The build scripts will handle updating the PHP SDK if new version is available.
It's recommended that the PHP SDK is unzipped into the shortest possible path, preferrably somewhere near the root drive. Therefore, this script will create a `php-sdk` folder in the C:\ drive. This `php-sdk` folder will remain unless you remove it yourself. For ongoing development, it's suggested you keep it around. The build scripts will handle updating the PHP SDK if new version is available.
If this is not the first time you build the drivers for a PHP version with certain configuration options (such as arch, thread safe, etc.), you will be prompted whether to rebuild, clean or superclean. Choose `rebuild` if you have always used the same configuration. Otherwise, choose `clean` to remove previous builds (binaries). The last option will remove the entire `php-<version>-src` directory, which is often unnecessary.
#### Steps
1. Launch a regular `cmd` prompt
2. Change to the directory where the Python scripts `builddrivers.py` and `buildtools.py` are
3. Interactive mode:
* Run `py builddrivers.py` to use the interactive mode. Use lower cases to answer the following questions:
* PHP Version (i.e. the version number like `7.1.7` or `7.2.0beta2`)
* 64-bit?
* Thread safe?
* Driver?
* Debug enabled?
* Download source from GitHub?
* For `yes/no` questions, you can simply hit `ENTER` key for `yes`. Other questions are self-explanatory.
4. Use Command-line arguments
* Run `py builddrivers.py -h` to get a list of options and their descriptions
* For example,
* `py builddrivers.py -v=7.1.7 -a=x86 -t=ts -d=all -g=no`
* `py builddrivers.py --PHPVER=7.0.22 --ARCH=x64 --THREAD=nts --DRIVER=sqlsrv --GITHUB=yes`
5. If the script detects the presence of a PHP source directory, you will be prompted whether to rebuild, clean or superclean. Choose
* `rebuild` if you have always used the same configuration (32 bit, thread safe, etc.)
* `clean` to remove previous builds (binaries)
* `superclean` to remove the entire `php-<version>-src` directory, which is often unnecessary
6. If you choose not to download from a GitHub repository, you will be asked to provide the full path to your local Source folder.
7. If the compilation is successful, you will be given the option to rebuild or quit.
#### Troubleshooting
When something goes wrong during the build, the log file will be launched (you can find the log files in `C:\php-sdk`). Otherwise, the log file will not be shown, and they remain in `C:\php-sdk` until you remove them manually.
After the compilation is complete, you will be given the option to rebuild or quit. If you choose rebuild, the extensions will be re-compiled (say after you have changed any source or header file). This script will keep running until you choose to quit.
In addition to the log files in `C:\php-sdk`, you can examine the contents of `C:\php-sdk\phpsdk-build-task.bat`, which is overwritten every time you run the build scripts.
When running build unattended, you should specify the destination path `--DESTPATH=<some valid path>`. In such case, the `php-sdk` folder will be created in the same working directory of these build scripts, and the drivers will be copied to your designated path. The script `builddrivers.py` provides an example for this case. Again, it's your choice whether to remove the `php-sdk` folder afterwards.
#### Building the extensions unattended
You can invoke `py builddrivers.py` with the desired options plus the destination path `--DESTPATH=<some valid path>`.
In such case, the `php-sdk` folder will be created in the same directory of these build scripts. Note that the PHP drivers will also be copied to the designated path.
The script `builddrivers.py` provides an example for this case. Again, it's your choice whether to remove the `php-sdk` folder afterwards.

View file

@ -296,7 +296,7 @@ class BuildUtil(object):
else: # pdo_sqlsrv
cmd_line = ' --enable-pdo --with-pdo-sqlsrv=shared ' + cmd_line
cmd_line = 'cscript configure.js --disable-all --enable-cli --enable-cgi' + cmd_line + ' --disable-ipv6 --with-odbcver=0x0380 --enable-embed'
cmd_line = 'cscript configure.js --disable-all --enable-cli --enable-cgi --enable-embed' + cmd_line
if self.thread == 'nts':
cmd_line = cmd_line + ' --disable-zts'
return cmd_line