节俭:找不到类“节俭\运输\ TSocket”

时间:2019-05-29 06:48:50

标签: php thrift

我正在遵循使用Apache Thrift的客户端和php服务器的官方教程。我的问题是它无法识别TSocket类。

命名空间会出现问题吗?

错误:

  

致命错误:找不到“ Thrift \ Transport \ TSocket”类   D:\ Calculadora \ tutorial \ php \ PhpClient.php,第45行

<?php

namespace tutorial\php;

error_reporting(E_ALL);

require_once __DIR__.'/../../lib/php/lib/ClassLoader/ThriftClassLoader.php';

use Thrift\ClassLoader\ThriftClassLoader;

$GEN_DIR = realpath(dirname(__FILE__).'/..').'/gen-php';

$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__ . '/../../lib/php/lib');
$loader->registerDefinition('shared', $GEN_DIR);
$loader->registerDefinition('tutorial', $GEN_DIR);
$loader->register();


use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\THttpClient;
use Thrift\Transport\TBufferedTransport;
use Thrift\Exception\TException;

try {
  $socket = new THttpClient('localhost', 8080, '/php/PhpServer.php');
  $socket = new TSocket('localhost', 9090);
  $transport = new TBufferedTransport($socket, 1024, 1024);
  $protocol = new TBinaryProtocol($transport);
  $client = new \tutorial\CalculatorClient($protocol);

  $transport->open();


} catch (TException $tx) {
  print 'TException: '.$tx->getMessage()."\n";
}

?>

0 个答案:

没有答案