PHP code example of google / cloud-dlp
1. Go to this page and download the library: Download google/cloud-dlp 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-dlp example snippets
use Google\Cloud\Dlp\V2\DlpServiceClient;
use Google\Cloud\Dlp\V2\ContentItem;
use Google\Cloud\Dlp\V2\InfoType;
use Google\Cloud\Dlp\V2\InspectConfig;
$dlpServiceClient = new DlpServiceClient();
$infoTypesElement = (new InfoType())
->setName('EMAIL_ADDRESS');
$inspectConfig = (new InspectConfig())
->setInfoTypes([$infoTypesElement]);
$item = (new ContentItem())
->setValue('My email is [email protected].');
$formattedParent = $dlpServiceClient
->projectName('[PROJECT_ID]');
$response = $dlpServiceClient->inspectContent($formattedParent, [
'inspectConfig' => $inspectConfig,
'item' => $item
]);
$findings = $response->getResult()
->getFindings();
foreach ($findings as $finding) {
print $finding->getInfoType()
->getName() . PHP_EOL;
}