0

I want to write PHP based thrift API client like thirft.apache.org example client in python at: http://thrift.apache.org/

I write this code:

      //A struture
      $up = UserProfile($uid=1,
             $name="Mark Slee",
             $blurb="I'll find something to put here.");

      # Talk to a server via TCP sockets, using a binary protocol
      $fp = fsockopen("localhost",9090, $errno, $errstr, 90);
      # Use the service we already defined
      $service=fwrite($fp, $up);

      while (!feof($fp)) {
          echo fgets($fp, 128);
      }

so is it correct alternative of python client code at : http://thrift.apache.org/

Please give any suggestion as I am new to it.

thanks

Hafiz
  • 4,187
  • 12
  • 58
  • 111

1 Answers1

2

Look in the Thrift Wiki at the Thrift Usage page. That has examples in many supported languages, in particular, there's an example client in PHP.

Pablo
  • 8,644
  • 2
  • 39
  • 29
  • I have seen this at many places but don't know that from where can I get thses files: `$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'; ` Where will these files? Will I download it from some where or I will need to install some thing for it? – Hafiz Nov 23 '11 at 21:26
  • 1
    They're part of the download package for Thrift available here: http://thrift.apache.org/download/ Download and extract the contents of the tar file and look in the `lib/php/src` directory. – Pablo Nov 23 '11 at 21:50
  • In windows , after installing will it go to windows directory? – Hafiz Nov 24 '11 at 00:02
  • do you know that where will it be installed if I will use .exe files under windows. because I think tar file is for linux? – Hafiz Nov 24 '11 at 00:58
  • 1
    The .exe file for windows is only the thrift *compiler*. In addition to that, you need the support files provided in the .tar file. – Pablo Nov 24 '11 at 01:28
  • ok so these are just simple files that I will place on my server on linux or windows and will just include them, while .exe file is compiler that will be required for writing thrift server not client? – Hafiz Nov 24 '11 at 09:06
  • I got from it what I asked that's why I am marking it right answer however I am still confuse about the `service` file but I think this is a different question, thanks Pablo – Hafiz Nov 24 '11 at 23:45