8000 GitHub - tengzhu/thrift
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

tengzhu/thrift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thrift Demo. PHP client call CPP server

What is Thrift

Thrift is an interface definition language and binary communication protocol that is used to define and create services for numerous languages. It is used as a remote procedure call (RPC) framework and was developed at Facebook for "scalable cross-language services development". It combines a software stack with a code generation engine to build services that work efficiently to a varying degree and seamlessly between C#, C++ (on POSIX-compliant systems), Cappuccino, Cocoa, Delphi, Erlang, Go, Haskell, Java, Node.js, OCaml, Perl, PHP, Python, Ruby and Smalltalk. Although developed at Facebook, it is now an open source project in the Apache Software Foundation. The implementation was described in an April 2007 technical paper released by Facebook, now hosted on Apache. -- From Wiki Apache Thrift

This Demo

PHP client call CPP server.

Work Flow

  1. PHP client call with Request.
  2. CPP server response with Response.

image

Thrift interface definition

namespace cpp TTG
namespace php TTG

enum ResponseState {
    StateOk = 0,
    StateError = 1,
    StateEmpty = 2
}

struct Request {
    1: i32 studentID = 0
}

struct Response {
    1: i32 studentID = 0,
    2: string name,
    3: list<string> infos,
    4: ResponseState state
}

service TTGService {
    Response getStudentInfo(1: Request request);
}


Folders

CPP // CPP server source files
--CMakeLists.txt //CMake file
--... // Other cpp source files
PHP //PHP client source files
--Gen // Generated by thrift
--Thrift // Thrift php source files
--client.php // Client source file
ThriftGen // files generated by thrift
--gen-cpp
--gen-php
--TTG.thrift // definition file

How to run

Preparation

  • CMake, make, g++ ...
  • php, web server(apache or nginx, php-fpm)
  • thrift (How to install)

Compile and run

  1. cd ThriftDemo/CPP
  2. mkdir build
  3. cd build
  4. cmake ..
  5. make
  6. ./TTG.run // Run the CPP server
  7. Run ThriftDemo/PHP/client.php

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

0