PHP Thrift client

Directory structure

PHP config

PHP code

<?php
$GLOBALS['THRIFT_ROOT'] = 'thrift';

require_once 'thrift/Thrift.php';
require_once 'thrift/transport/TTransport.php';
require_once 'thrift/transport/TSocket.php';
require_once 'thrift/protocol/TBinaryProtocol.php';
require_once 'thrift/transport/TFramedTransport.php';
require_once 'thrift/transport/TBufferedTransport.php';

require_once 'thrift/packages/MyService/MyService.php';
require_once 'thrift/packages/MyService/MyService_types.php';

$transport = new TSocket('localhost', 7911);
$transport->open();

$protocol = new TBinaryProtocol($transport);

$client= new MyServiceClient($protocol, $protocol);

$result = $client->operation('param1', 'param2');

Print 'result = ' . $result;

$transport->close();
?>

PHP Notes

* Sets must be of primitives, not structs. If you're getting an error like this, it's because of that. Switch from a Set to a List.  $this->success[$elem40] = true; It says "illegal offset type" 

ThriftUsagePhp (last edited 2010-06-18 22:17:23 by DavidEhrmann)