Я следую официальному руководству для клиента и php-сервера с использованием Apache Thrift. Моя проблема в том, что он не распознает класс 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";
}
?>