thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pete Wyckoff <>
Subject -rest -java?
Date Mon, 15 Sep 2008 18:03:44 GMT

Are there any current plans for supporting the -rest flag in java?

Thanks, pete


Mark Slee mslee at
Mon Nov 19 17:22:25 PST 2007

    * Previous message: [Thrift] PHP Development
    * Next message: [Thrift] Re: Thrift + Apache
    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Hi Andrew,

This isn't the primary design case for Thrift, but you can use Thrift to
help structure this sort of code. Facebook uses Thrift in the
implementation of our REST web-services API.

General approach:

Define your types and web service in a .thrift file.
Generate PHP code using -rest flag.

Thrift generates a REST handler for your service implementation, which
you can invoke by passing the request variables. So you would have
something like:

$impl = new ServiceImplementation(); // your class that implement
$rest = new ServiceRest($_REQUEST); // generated handler

Then you can invoke something like:

$method = $_REQUEST['method'];
$result = $rest->$method($request);

This will dispatch into your $impl class which can return a Thrift
object as $result.

We have common PHP functions that generically convert any Thrift object
into generic XML or JSON just by iterating over the elements.

So... it's not the primary use case, but Thrift is a nice way to
separate the data/types and method implementations from the
encoding/decoding details of input/output (i.e. GET params vs. JSON,


-----Original Message-----
From: thrift-bounces at
[mailto:thrift-bounces at] On Behalf Of Andrew Eross
Sent: Sunday, November 18, 2007 6:42 PM
To: thrift at
Subject: [Thrift] PHP Development

Hi folks,

Simple question about thrift that I haven't quite been able to discern
from the available documentation...

We have a bunch of PHP class libraries that we would like to expose as
a number of different web services. The same libraries will be
implemented in a few different ways and accessible via REST/JSON and

We're trying to decide if thrift may be helpful as an abstract way of
implementing these services to be accessible by PHP. We're about to
dive in a give it a go, but wanted to ask the community if this is
what thrift is intended for.

Thrift mailing list
Thrift at

View raw message