PHP code example of google / cloud-databasecenter
1. Go to this page and download the library: Download google/cloud-databasecenter 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/ */
google / cloud-databasecenter example snippets
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\DatabaseCenter\V1beta\Client\DatabaseCenterClient;
use Google\Cloud\DatabaseCenter\V1beta\Product;
use Google\Cloud\DatabaseCenter\V1beta\QueryProductsRequest;
// Create a client.
$databaseCenterClient = new DatabaseCenterClient();
// Prepare the request message.
$request = (new QueryProductsRequest())
->setParent($parent);
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $databaseCenterClient->queryProducts($request);
/** @var Product $element */
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}