Reprint Address: http://blog.csdn.net/hshxf/article/details/5666145
1, Prepare thrift PHP Client base class, this can be obtained from the thrift source package, under THRIFTSRC/LIB/PHP/SRC, generally have the following directories and files: Ext,protocol,transport directory and thrift.php, autoload.php files, we copy these files and directories to a specified thrift root directory, such as C:/php/thrift/root
2, if it is a Linux environment, you can consider using Thrift protocol PHP Extension, compiling method: First of all mentioned in the Ext directory under the Thrift_protocol directory copy to your PHP source under the Ext directory, pay attention to modify permissions , you can directly modify to 777 permissions, and then start to enter into the Thrift_protocol directory to start compiling, in turn, execute the following command: Phpize,./configure--enable-thrift_protocol,make, Then moudles/thrift_protocol.so copy to your PHP installation directory in the ETC directory, such as PHP5/ETC, and then configure the php.ini file, restart Apache
3, using thrift--gen PHP xxx.thrift Compile the interface file, and then copy the interface file to thrift root under the packages directory, such as C:/php/thrift/root/packages
4, write client code, referring to the thiftsrc//tutorial/php under the phpclient.php, must pay attention to the first few lines of the global variable settings
$GLOBALS [' thrift_root '] = '. /.. /lib/php/src ';
require_once $GLOBALS [' thrift_root ']. ' /thrift.php ';
require_once $GLOBALS [' thrift_root ']. ' /protocol/tbinaryprotocol.php ';
require_once $GLOBALS [' thrift_root ']. ' /transport/tsocket.php ';
require_once $GLOBALS [' thrift_root ']. ' /transport/thttpclient.php ';
require_once $GLOBALS [' thrift_root ']. ' /transport/tbufferedtransport.php ';