christophmccann
christophmccann

Reputation: 4211

Using thrift with PHP and Java

I am getting myself a bit confused about how to go about this. My plan is to use PHP to perform the final page construction and this PHP web app will contact multiple services, which i will also to develop, for the data. Lets say one of those services was done in Java. I would define a Java interface which was implemented by a concrete class. This is where I get confused - how does Thrift link the PHP web app with the java service or am I getting totally mixed up??

Thanks

Upvotes: 3

Views: 5100

Answers (2)

Alex
Alex

Reputation: 11

I would be very curious to see benchmarks between Thrift and PHP / Java bridge http://php-java-bridge.sourceforge.net/pjb/. By heart i would advocate Thrift but i have doubts it is as fast as php/java bridge.

Upvotes: 1

Roberto Aloi
Roberto Aloi

Reputation: 30985

Thrift is based on the use of an IDL (Interface Definition Language). Using the definition from Wikipedia:

An interface description language (or alternately, interface definition language), or IDL for short, is a specification language used to describe a software component's interface. IDLs describe an interface in a language-neutral way, enabling communication between software components that do not share a language – for example, between components written in C++ and components written in Java.

An example on how to use the Thrift interface language is available in the Thrift tutorial.

By the use of a .thrift file, you're suppose to define the interfaces you need (in terms of types and services). For example, in your .thrift file, you could define a simple function like:

i32 add(1:i32 num1, 2:i32 num2)

that represents a function to sum two integers.

When you're ready with your .thrift file, you can generate the Java, PHP, Erlang, whatever code that you need (server-side or client-side), using the Thrift generator.

Refer to the Thrift wiki for more information.

Upvotes: 6

Related Questions