I am following the official tutorial for a client and php server using Apache Thrift. My problem is that it does not recognize the TSocket class.
Will I have problems with the namespace?
Error:
Fatal error: Class 'Thrift\Transport\TSocket' not found in D:\Calculadora\tutorial\php\PhpClient.php on line 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()."
";
}
?>