PHP code example of swoole-foundation / swoole-thrift
1. Go to this page and download the library: Download swoole-foundation/swoole-thrift library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
swoole-foundation / swoole-thrift example snippets
/**
* thrift服务端
* @author xialeistudio
* @date 2019-05-16
*/
use swoole\foundation\thrift\factory\TFramedTransportFactory;
use swoole\foundation\thrift\server\SwooleServer;
use swoole\foundation\thrift\server\SwooleServerTransport;
use Swoole\Server;
use tests\handler\SumServiceImpl;
use tests\services\SumService\SumServiceProcessor;
use Thrift\Exception\TTransportException;
use Thrift\Factory\TBinaryProtocolFactory;
printf("Server::serve on %s:%d\n", $server->host, $server->port);
});
$server->serve();
} catch (TTransportException $e) {
printf("Server::serve error: {$e->getMessage()}\n");
}