如何设置PHP客户端Thrift 0.9.1 ...

时间:2014-02-14 14:08:45

标签: php namespaces thrift

我正在尝试使用HBase Thrift服务器为RPC设置一个php客户端但是我在开始时遇到了一些错误...我已经编译了HBase.thrift文件(使用0.9.1编译器)和我把2个生成的文件放在下面(/是我项目的根目录,我在ArchOS上使用apache服务器):

  • /include/Hbase.php
  • /include/Types.php

我在/下包含了thrift0.9.1 / lib / php / lib(由Thrift和子文件夹组成)的lib文件夹,所以我有以下文件系统:

  • /include/HBase.php
    • /Types.php
  • /节俭/基
    • /类加载器
    • /异常
    • / ext
    • ...

为了能够使用我的服务(HBase.php)我要加载文件,所以我的代码如下:

<?php 
$GLOBALS['THRIFT_ROOT'] = PHYSICAL_PATH;

 // Load up all the thrift stuff
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Transport/TTransport.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Transport/TSocket.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Protocol/TProtocol.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Protocol/TBinaryProtocol.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Transport/TBufferedTransport.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Type/TMessageType.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Factory/TStringFuncFactory.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/StringFunc/TStringFunc.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/StringFunc/Core.php';  
require_once $GLOBALS['THRIFT_ROOT'].'Thrift/Type/TType.php';  
use Thrift\Protocol\TBinaryProtocol;  
use Thrift\Transport\TSocket;  
use Thrift\Transport\TSocketPool;  
use Thrift\Transport\TFramedTransport;  
use Thrift\Transport\TBufferedTransport; 

//hbase thrift
require_once ('Hbase.php');
require_once ('Types.php');
?>

当我对不同的文件收费时,我收到此行的错误--require_once('Types.php'); - 并且错误是:致命错误:类'Thrift \ Exception \ TException'在1266行的/var/www/html/POCThrift2/include/Types.php中找不到

我理解如下:当我尝试包含Types.php时,Thrift \ Exception \ TException命名空间未被使用(尽管使用Thrift \ Exception \ TException;在Types文件的beginig中)但我不知道知道我为什么会得到他的错误......你能帮助我吗?有没有人以前遇到过这个问题?提前谢谢你,我现在就是stuuuck ......

0 个答案:

没有答案