Apache Thrift Hello World with PHP and Python Part 2

In the previous post – Apache Thrift Hello World with PHP and Python Part 1, I wrote how to code server python with Apache Thrift. And, the second part, and it is the last one as well, I will show you the way how to writing the client with Laravel 4.2

You could clone full source from here: https://github.com/thanhson1085/thrift-laravel

Please download the source code before reading next steps.


What you get by achieving your goals is not nearly as important as what you become by achieving your goals

Step 1: Add Apache Thrift client libraries to Laravel

Create directory: app/libs

Add put all external libraries to that directory.

Includes libraries to Laravel autoload by adding the lib path to composer.json file:

And run composer update :

Step 2: Add a route

Add routes (app/routes.php):

Step 3: Create Hello Controller

Laravel HelloController (HelloController.php):

With source code above, You can see that thrift client will be connect to server at port 9093, localhost, and timeout is 3600 seconds.

Step 4: Run a Test

Run Thrift Server (refer to part 1):

Run client request: