Install Transactd PHP client on Mac OS X 10.11 or later

On Mac OS X 10.11 and later, due to limitations of SIP, you can not install the client shared modules in the default directory /usr/lib.

/usr/bin/php-config is used in installing Transactd PHP client. But it does not return correct infomation on Mac OS X 10.11 or later.

By preparing the following, it becomes possible to build and install clients like previous versions of OS X, without disabling SIP.

The following contents are confirmed with OS X 10.12 and Transactd 3.7.2 or later.

Mapping source code

php-config command is used by the building process of Transactd PHP client. There is php-config in /usr/bin. But the result of php-config --include-dir is /usr/lnclude/php, which is not the correct source path.

We found it on the OS X 10.12 machine, in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php. So make the symbolic link to the path.

cd /usr
sudo mkdir include
cd include
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/php php

Make PHP include directory

Transactd PHP client consists of extension module and transactd.php. It is convenient to place transactd.php in PHP's include path.

But there is no include path of PHP installed in OS X by the default. So we make it.

cd /usr
sudo mkdir local
cd local
sudo mkdir php
cd php
sudo mkdir include

Make PHP extension-dir

Since extension-dir is under /usr/lib by default, it is impossible to copy the extension that you built to there, because of limitations of SIP. So we create extension-dir in another location.

cd /usr/local/php
sudo mkdir extensions

Copy the contents of the existing extension-dir. Check the copy source directory with php-config --extension-dir.

php-config --extension-dir
=> /usr/lib/php/extensions/no-debug-non-zts-20131226

sudo cp /usr/lib/php/extensions/no-debug-non-zts-20131226/* /usr/local/php/extensions

Edit php.ini

Open /etc/php.ini with vi editor:

sudo vi /etc/php.ini

Replace or add the following lines:

include_path=.:/usr/local/php/include
extension-dir=/usr/local/php/extensions

Run CMake

From here, it is the same as the previous versions of OS X or Linux. Specify the directories created above when executing cmake.

cmake .. -DTRANSACTD_PHP=ON -DBOOST_ROOT=~/boost_1_59_0 \
  -DTRANSACTD_CLIENTS_PREFIX=/usr/local/lib
  -DPHP_EXTENSION_DIR=/usr/local/php/extension