PHP code example of sy-records / thrift2-hbase
1. Go to this page and download the library: Download sy-records/thrift2-hbase 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/ */
sy-records / thrift2-hbase example snippets
declare(strict_types=1);
return [
'default' => [
'host' => env('ALIHBASE_HOST', 'localhost'),
'port' => env('ALIHBASE_PORT', 9190),
'key_id' => env('ALIHBASE_KEYID', 'root'),
'signature' => env('ALIHBASE_SIGNATURE', 'root'),
],
];
declare(strict_types=1);
namespace App\Controller;
use Hyperf\Di\Annotation\Inject;
use Luffy\AliHbaseThrift\Service\AliHbaseThriftInterface;
class IndexController extends AbstractController
{
/**
* 使用注解时
* @Inject()
* @var AliHbaseThriftInterface
*/
private $hbase;
public function index()
{
/**
* @var $client \Luffy\Thrift2Hbase\THBaseServiceClient
*/
$client = $this->hbase->getClient();
/**
* @var $hbase \Luffy\AliHbaseThrift\Service\AliHbaseThriftService
*/
$hbase = make(AliHbaseThriftInterface::class);
/**
* @var $client \Luffy\Thrift2Hbase\THBaseServiceClient
*/
$client = $hbase->getClient();
$res = $client->get("scanface:test", new \Luffy\Thrift2Hbase\TGet(["row" => "001"]));
var_dump($res->columnValues);
}
}
return [
'host' => "localhost",
'port' => 9190,
'key_id' => 'root',
'signature' => 'root',
];
$hbase = new Luffy\AliHbaseThrift\Service\AliHbaseThriftService($config['host'], $config['port'], $config['key_id'], $config['signature']);
shell
php bin/hyperf.php vendor:publish sy-records/thrift2-hbase