Transactd Installation Guide for PHP
This document is for the previous version of 2.4.0. If you want to build a later version, please see the latest document.
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.
- PHP 5.6 VC11 x86/x64 Thread Safe/Non Thread Safe
- PHP 5.5 VC11 x86/x64 Thread Safe/Non Thread Safe
- PHP 5.4 VC9 x86/x64 Thread Safe/Non Thread Safe
- Download and extract Zip archive which is suitable to your PHP version from Transactd download page - Transactd client for PHP.
- Copy file and add settings according to
README_PHP
.- Copy
php_transactd.dll
to PHPextension_dir
. - Copy
transactd.php
to PHPinclude_path
. - Copy
tdclc_*.dll
andtdclcpp_*.dll
to the same folder asphp.exe
is placed. - Copy
tests\transactd
folder tophp\tests
. - Add the following line to
php.ini
:extension=php_transactd.dll
extension_dir
andinclude_path
are found inphpinfo()
.) - Copy
- Open
phpinfo()
and make sure thattransactd
is there. - XAMPP Windows 5.6.3
- XAMPP Windows 5.5.19
- XAMPP Windows 1.8.2
- XAMPP Windows 1.8.3
- If apache and MySQL server on XAMPP are running, stop them.
- Download and extract Zip archive which is suitable to your XAMPP version from Transactd download page - Transactd client for XAMPP.
- 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
- Double-click
install.bat
. - 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. - If XAMPP not found, it says
Please input XAMPP 1.8.2 folder (for example C:\xampp):
. Enter the XAMPP installation path. - Confirmation message for the installation is displayed. Enter Y to confirm. Then file copying will be started.
- 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. - The installation is complete with appearing
Install done.
. Start apache and MySQL server on XAMPP. Openphpinfo()
to make sure thattransactd
is there.
(Currently, binaries for other 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:
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:
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
Here, I example build and install in Ubuntu.
2-1. Checking PHP configuration
Make sure the information that required to build Transactd client.
Thread Safety
Find out that PHP is thread safe version or not. Run the following command:
php -i | grep Thread
- If
Thread Safety => enabled
, the PHP is thread safe version. - If
Thread Safety => disabled
, the PHP is non thread safe version.
include_dir
Examine include directory of PHP with the following command:
php-config --include-dir
(ex.) => /usr/include/php5
2-2. Install CMake
Transactd clients requires CMake to build them.
sudo aptitude install cmake
2-3. Install SWIG (for Transactd 2.0 or earlier)
PHP client for Transactd 2.0 or earlier requires SWIG (2.0 or later) to build them. It is not required by Transactd 2.1 or later.
sudo aptitude install swig2.0
2-4. 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-5. 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-6. Install Transactd client
Then run following commands to build and install Transactd clients:
cd ~/transactd
mkdir bld
cd bld
cmake .. -DTRANSACTD_PHP=ON -DBOOST_ROOT=~/boost_1_58_0 \
-DTRANSACTD_PHP_ZTS=OFF \
-DTRANSACTD_PHP_SOURCE_ROOT=/usr/include/php5/ \
-DTRANSACTD_CLIENTS_PREFIX=/usr/lib
make
sudo make install
TRANSACTD_PHP_ZTS
isON
with thread-safe version PHP,OFF
with non-thread-safe version PHP.TRANSACTD_PHP_SOURCE_ROOT
isinclude_dir
which was determined in step 2-1.TRANSACTD_CLIENTS_PREFIX
is install-prefix forlibtdclc_*.so
which is required by PHP client. Default is/usr/lib
.
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_PHP_ZTS=OFF \
-DTRANSACTD_PHP_SOURCE_ROOT=/usr/include/php5/ \
-DTRANSACTD_CLIENTS_PREFIX=/usr/lib \
-DTRANSACTD_PHP_INCLUDE_PATH=/Applications/XAMPP/xamppfiles/include/
2-7. Installing and configuring the PHP extension
Check the PHP extensions directory with the following command, and then copy the extension file to there:
php -i | grep extension_dir
(ex.) => extension_dir => /usr/lib/php5/20100525
sudo cp bin/php_transactd.so /usr/lib/php5/20100525/
Check the PHP include path with the following command, and then copy generated script file to there:
php -i | grep include_path
(ex.) => include_path => .:/usr/share/php:/usr/share/pear
sudo cp bin/transactd.php /usr/share/php/
Add extension=php_transactd.so
to PHP setting file:
php -i | grep "Configuration File"
(ex.) => Configuration File (php.ini) Path => /etc/php5/cli
echo extension=php_transactd.so > /etc/php5/cli/conf.d/transactd.ini
Check the installation status with phpinfo()
or the following command:
php -i | grep ^transactd -A 3
(ex.)
transactd
Version => 1.1.3
Required Module => libtdclc_64.so.1.1
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
- If
Thread Safety => enabled
, the PHP is thread safe version. - If
Thread Safety => disabled
, the PHP is non thread safe version.
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.
Compiler | Architecture | Required 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.
- For Visual C + + 2008 Express Edition, open it from [Start menu] - [All Programs] - [Microsoft Visual C++ 2008 Express Edition] - [Visual Studio Tools] - [Visual Studio 2008 Command Prompt].
- For Visual Studio 2012 Express (x86), open it from [Start menu] - [All Programs] - [Microsoft Visual Studio 2012] - [Visual Studio Tools] - [VS2012 x86 Native Tools Command Prompt].
- For Visual Studio 2012 Express (x64), open it from [Start menu] - [All Programs] - [Microsoft Visual Studio 2012] - [Visual Studio Tools] - [VS2012 x64 Cross Tools 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 SWIG (for Transactd 2.0 or earlier)
PHP client for Transactd 2.0 or earlier requires SWIG (2.0 or later) to build them. It is not required by Transactd 2.1 or later.
Download swigwin-3.0.2.zip (latest on 2014/09/10) from SWIG download page and extract it.
Then add folder path where swig.exe is to environment variable PATH. You can add the environment variable from [Control Panel] - [System] - [Advanced].
Start command prompt and run following command. If SWIG is installed correctly, version information is displayed.
swig -version
3-5. 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:\Program Files\boost\boost_1_58_0
Start the Visual Studio command prompt. Run the following commands to build Boost:
cd C:\Program Files\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
@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
- If you are building the 64bit version of Boost, add
address-model=64
. Remove it if the 32bit version. - In the case of Visual C++ 2008, you can explicitly specify the version of Visual Studio with
toolset=msvc-9.0
. - In the case of Visual C++ 2012, you can explicitly specify the version of Visual Studio with
toolset=msvc-11.0
.
Then, add new environment variable TI_BOOST_ROOT_32
and TI_BOOST_ROOT_64
,
set the value to boost folder of 64bit and 32bit.
There is no need to set both. You should set variable for your build bitness.
For 64bit
TI_BOOST_ROOT_64 = C:\Program Files\boost\boost_1_58_0
For 32bit
TI_BOOST_ROOT_32 = C:\Program Files\boost\boost_1_58_0
You can add the environment variable from [Control Panel] - [System] - [Advanced].
3-6. 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:
- 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.
- Create a folder
c:\php-sdk
. - 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
- Open Visual Studio command prompt and run the following command:
cd c:\php-sdk bin\phpsdk_setvars.bat bin\phpsdk_buildtree.bat phpdev
- 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. - 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
- 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
- We finish preparing here, because Transactd client does not need other than header file.
3-7. 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-8. 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 ^
-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
Visual Studio 9 2008
is for Visual C++ 2008 x86.Visual Studio 11
is for Visual C++ 2012 x86.Visual Studio 11 Win64
is for Visual C++ 2012 x64.TRANSACTD_PHP_ZTS
isON
with thread-safe version PHP,OFF
with non-thread-safe version PHP.TRANSACTD_PHP_SOURCE_ROOT
is the path of the source code of PHP which is prepared in step 3-6.TRANSACTD_PHP_LIBRARY_PATH
is the path to the lib file that you found in step 3-1.
Open generated project file tdcl.sln
.
Change build configuration to [Release] in [Build] - [Configuration Manager].
Then build solution with [Build] - [Build Solution].
3-9. 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_0.dll
(snip)