PHP code example of woodynew / hyperf-thrift-client

1. Go to this page and download the library: Download woodynew/hyperf-thrift-client 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/ */

    

woodynew / hyperf-thrift-client example snippets


    
    /**
     * thrift客户端,共用一个连接
     * @author woody
     * @date 2023-04-09
     */
    
    use Woodynew\Hyperf\ThriftClient\Transport;
    use tests\services\SumService\SumServiceClient;
    use Thrift\Protocol\TBinaryProtocol;
    use Thrift\Transport\TFramedTransport;
    
    0; $i++) {
        $start = microtime(true);
        $client->sum(1, 1);
        $duration = microtime(true) - $start;
        $max = max($duration, $max);
        $min = $min === 0 ? $duration : min($duration, $min);
        $count++;
        $total += $duration;
    }
    
    printf("max: %fs\nmin: %fs\navg: %fs\ncall count: %d\ntotal time: %fs\n", $max, $min, $total / $count, $count, $total);