Transactd Installation Guide for PHP

Build and installation has been simplified from Transactd 2.4.2. (Especially on Linux / Mac OS X)
If you want to build 2.4.0 or earlier version, please see the old document.

Install Transactd client according to PHP you are using, and exec tests.

1. Installation according to PHP you are using

Installing pre-built binary (Windows)

Official PHP distribution for Windows

If you use the following PHP that is distributed in PHP for Windows: Binaries and Sources, you can install pre-built binaries.

(Currently, binaries for other versions of PHP are not provided. Please refer to Building and installing from source code to build it yourself.)

You can install pre-built binaries according to following procedure:

  1. Download and extract Zip archive which is suitable to your PHP version from Transactd download page - Transactd client for PHP.
  2. Copy file and add settings according to README_PHP.
    • Copy php_transactd.dll to PHP extension_dir.
    • Copy transactd.phpto PHP include_path.
    • Copy tdclc_*.dll and tdclcpp_*.dll to the same folder as php.exe is placed.
    • Copy tests\transactd folder to php\tests.
    • Add the following line to php.ini:
      extension=php_transactd.dll
    (extension_dir and include_path are found in phpinfo().)
  3. Open phpinfo() and make sure that transactd is there.

PHP included in XAMPP for Windows

If you use PHP that is included in apache friends - xampp for windows, you can install Transactd client for PHP and Transactd plugin for MySQL together.

You can install pre-built binaries according to following procedure:

  1. If apache and MySQL server on XAMPP are running, stop them.
  2. Download and extract Zip archive which is suitable to your XAMPP version from Transactd download page - Transactd client for XAMPP.
  3. Move extracted files to XAMPP folder. For example, folders are as follows:
    c:\xampp\transactd_1.1.1_for_xampp-win32-1.8.2-3-VC9
  4. Double-click install.bat.
  5. The installation script detect your XAMPP path automatically. If XAMPP found, it says XAMPP found on path\to\xampp. Use it? [Y/N]:. Enter Y if folder is correct or N if not.
  6. If XAMPP not found, it says Please input XAMPP 1.8.2 folder (for example C:\xampp):. Enter the XAMPP installation path.
  7. Confirmation message for the installation is displayed. Enter Y to confirm. Then file copying will be started.
  8. It says Do you want to run `install plugin transactd` SQL now? [Note] Please START MySQL before run it. [Y/N]: after copying. If you want to install Transactd Plugin to MySQL, enter Y after you start the MySQL server on XAMPP.
  9. The installation is complete with appearing Install done.. Start apache and MySQL server on XAMPP. Open phpinfo() to make sure that transactd is there.

Building and installing from source code

Currently, there is no pre-built binary available for PHP other than the above.

For other PHP, please build and install according to the instructions below:

2. Building and installing in Linux / Mac OS X

* If you use Mac OS X 10.11 or later, please see Install Transactd PHP client on Mac OS X 10.11 or later too.

Here, I example build and install in Ubuntu.

CMake will get the php path information with the two commands: php -i and php-config. These commands must work on the target environment.

2-1. Install CMake

Transactd clients requires CMake to build them.

sudo aptitude install cmake

2-2. Download and build Boost C++ Libraries

Download source code from Boost download page and extract it.

cd ~
wget http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.gz/download \
     -O boost_1_58_0.tar.gz
tar xzf boost_1_58_0.tar.gz

Run the following commands to build Boost:

cd ~/boost_1_58_0
./bootstrap.sh --with-libraries=chrono,filesystem,system,thread,timer,serialization,program_options
./b2 cxxflags=-fPIC

2-3. Download Transactd source code

Download the latest transactd-source-*.*.*.zip from Transactd download page and extract it.

cd ~
wget http://www.bizstation.jp/al/transactd/download/transactd-2.4.2/transactd-source-2.4.2.zip
#On Mac OS X
#curl curl -O http://www.bizstation.jp/al/transactd/download/transactd-2.4.2/transactd-source-2.4.2.zip
unzip -q transactd-source-2.4.2.zip -d transactd

2-4. Build and install Transactd php client

Then run following commands to build and install Transactd php clients:

cd ~/transactd
mkdir bld
cd bld
cmake .. -DTRANSACTD_PHP=ON -DBOOST_ROOT=~/boost_1_58_0 -DTRANSACTD_CLIENTS_PREFIX=/usr/lib
make
sudo make install

If you use PHP included in XAMPP for Mac OS X, you must specify TRANSACTD_PHP_INCLUDE_PATH to use iconv that is included in the XAMPP:

cmake .. -DTRANSACTD_PHP=ON -DBOOST_ROOT=~/boost_1_58_0 \
  -DTRANSACTD_CLIENTS_PREFIX=/usr/lib \
  -DTRANSACTD_PHP_INCLUDE_PATH=/Applications/XAMPP/xamppfiles/include/

2-5. Check the installation status

Check the installation status with phpinfo() or the following command:

php -i | grep ^transactd -A 3
(ex.)
transactd
Version => 2.4.2
Required Module => libtdclc_64.so.2.4

3. Building and installing on Windows

3-1. Checking PHP configuration

PHP Version

Check the version of PHP. Open phpinfo() and search PHP Version. You can also use the following command:

php -i | findstr /B /C:"PHP Version"

Architecture

Check the PHP architecture (x86 or x64). Open phpinfo() and search Architecture. You can also use the following command:

php -i | findstr Architecture

Thread Safety

Find out that PHP is thread safe version or not. Open phpinfo() and search Thread Safety. You can also use the following command:

php -i | findstr Thread

Compiler

Examine the compiler needed to build. Open phpinfo() and search Compiler. You can also use the following command:

php -i | findstr Compiler

lib file

Usually, there is a lib file in dev\php5ts.lib or dev\php5.lib. Ensure the path because it will be required in later steps.

extension_dir

Find out the PHP extensions folder. Open phpinfo() and search extension_dir. You can also use the following command:

php -i | findstr extension_dir
(ex.) => extension_dir => ext

include_path

Find out the PHP include path.Open phpinfo() and search include_path. You can also use the following command:

php -i | findstr include_path
(ex.) => include_path => .;C:\php\pear

php.ini

Find out the path to the configuration file of PHP. Open phpinfo() and search Loaded Configuration File. You can also use the following command:

php -i | findstr /B /C:"Loaded Configuration File"
(ex.) => Loaded Configuration File => C:\php\php.ini

3-2. Download and install the compiler

Install the compiler which is suitable to Architecture and Compiler which was examined by step 3-1.

CompilerArchitectureRequired compiler and link to the Express version of it
MSVC9 (Visual C++ 2008)x86 Microsoft Visual C++ 2008
( Microsoft Visual C++ 2008 Express Edition)
MSVC11 (Visual C++ 2012)x86 Microsoft Visual C++ 2012
( Microsoft Visual Studio Express 2012 for Windows Desktop)
x64

How to start the Visual Studio Command Prompt

In procedure which will be described later, you should open the Visual Studio command prompt.

3-3. Download and install CMake

Download CMake Win32 Installer from CMake download page and run it.

Along the way, select "Add CMake to the system PATH for all (or current) users" to set path of cmake.exe.

3-4. Download and install Boost C++ Libraries

Download Boost source code from Boost download page and unzip it. Here, it is assumed that you have saved in the following folder:

C:\boost\boost_1_58_0

Start the Visual Studio command prompt. Run the following commands to build Boost:

cd C:\boost\boost_1_58_0
bootstrap.bat

@REM For 64bit
bjam.exe toolset=msvc threading=multi address-model=64 architecture=x86 ^
  --with-chrono --with-filesystem --with-system --with-thread --with-timer ^
  --with-serialization --with-program_options ^
  variant=debug,release link=static runtime-link=static,shared

@REM For 32bit
bjam.exe toolset=msvc threading=multi architecture=x86 ^
  --with-chrono --with-filesystem --with-system --with-thread --with-timer ^
  --with-serialization --with-program_options ^
  variant=debug,release link=static runtime-link=static,shared

3-5. Preparation of the PHP source code

Prepare PHP source code according to the steps in Build your own PHP on Windows. I will explain the step-by-step instructions below:

  1. Download the source code of PHP which is suitable to major and minor version of your PHP from PHP Snapshots. For example, if your PHP is version 5.4.22, download version 5.4 of the source code.
  2. Create a folder c:\php-sdk.
  3. Download php-sdk-binary-tools-20110915.zip, and extract it to c:\php-sdk. The folders will be as following:
    c:\php-sdk
        ├─bin
        ├─script
        └─share
  4. Open Visual Studio command prompt and run the following command:
    cd c:\php-sdk
    bin\phpsdk_setvars.bat
    bin\phpsdk_buildtree.bat phpdev
  5. The folders like C:\php-sdk\phpdev\vcXX\x86 will be created. Open the folder that matches the version and architecture to build. Create a suitable folder if it does not exist.
  6. Extract the source code archive of PHP. For example, the folders will be as following:
    c:\php-sdk
        ├─bin
        ├─script
        ├─share
        └─phpdev
            └─vc9
                └─x86
                    └─php5.4-201312050630
  7. Return to the command prompt which was opened in step 4, and run the following command:
    cd C:\php-sdk\phpdev\vc9\x86\php5.4-201312050630
    buildconf
    configure
  8. We finish preparing here, because Transactd client does not need other than header file.

3-6. Download Transactd source code

Download the latest transactd-source-*.*.*.zip from Transactd download page and extract it.

Here, it is assumed that you have saved in the following folder:

C:\Users\Public\Documents\transactd

3-7. Build Transactd client

Start the Visual Studio command prompt. Run the following command to generates a project file of Transactd client:

C:\Users\Public\Documents\transactd
md bld
cd bld
cmake .. -G "Visual Studio 9 2008" -DTRANSACTD_PHP=ON ^
  -BOOST_ROOT=C:\boost\boost_1_58_0
  -DTRANSACTD_PHP_ZTS=ON ^
  -DTRANSACTD_PHP_SOURCE_ROOT=C:\php-sdk\phpdev\vc9\x86\php5.4-201312050630 ^
  -DTRANSACTD_PHP_LIBRARY_PATH=C:\php\dev\php5ts.lib

Open generated project file TransactdPhpClient.sln. Change build configuration to [Release] in [Build] - [Configuration Manager]. Then build solution with [Build] - [Build Solution].

3-8. Installing and configuring the PHP extension

Copy build\tdclphp\Release\php_transactd.dll to the PHP extensions folder which found in step 3-1.

Copy build\tdclphp\transactd.php to the PHP include path which was found in step 3-1.

Copy bin\tdclc_*.dll and bin\tdclcpp_*.dll to the same folder as php.exe.

Add line extension=php_transactd.dll to the configuration file of PHP which was found in step 3-1.

Check the installation status with phpinfo() or the following command:

php -i
(ex.) (snip)
transactd

Version => 2.4.2
Required Module => tdclc_32_2_4.dll
      (snip)

4. Exec tests

Transactd tests use PHPUnit. Install PHPUnit and exec test files in source/bzs/test/tdclphp, *_Test.php. For example:

phpunit transactd_Test.php
phpunit transactd_v3_Test.php