Created
June 5, 2020 20:03
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
This post explains more about how to verify access to Bigtable with PHP