Skip to content

Instantly share code, notes, and snippets.

@craigafinch
Created June 5, 2020 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigafinch/ac41aa38eb1d7b5abc7921f54338c331 to your computer and use it in GitHub Desktop.
Save craigafinch/ac41aa38eb1d7b5abc7921f54338c331 to your computer and use it in GitHub Desktop.
A minimal test script to ensure that a PHP server can access data in Google BigTable (tests scopes, credentials, GRPC, and protobuf)
<?php
require 'vendor/autoload.php';
use Google\Cloud\Bigtable\BigtableClient;
$project_id = 'my-project-id';
$instance_id = 'my-instance-id';
$table_id = 'my-table-id';
$credential_file_path = './credential.json';
$transport = 'grpc';
// Connect to an existing table with an existing instance.
$dataClient = new BigtableClient([
'projectId' => $project_id,
'credentials' => $credential_file_path,
'transport' => $transport,
]);
$table = $dataClient->table($instance_id, $table_id);
// Read multiple rows
$rows = $table->readRows(['rowsLimit' => 2]);
foreach ($rows as $row) {
print_r($row) . PHP_EOL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment