PHP code example of google / cloud-secret-manager
1. Go to this page and download the library: Download google/cloud-secret-manager 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-secret-manager example snippets
use Google\Cloud\SecretManager\V1\Replication;
use Google\Cloud\SecretManager\V1\Replication\Automatic;
use Google\Cloud\SecretManager\V1\Secret;
use Google\Cloud\SecretManager\V1\SecretManagerServiceClient;
$client = new SecretManagerServiceClient();
$secret = $client->createSecret(
SecretManagerServiceClient::projectName('[MY_PROJECT_ID]'),
'[MY_SECRET_ID]',
new Secret([
'replication' => new Replication([
'automatic' => new Automatic()
])
])
);
printf(
'Created secret: %s' . PHP_EOL,
$secret->getName()
);