|
| 1 | +# Google DLP PHP Sample Application |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +This simple command-line application demonstrates how to invoke Google |
| 6 | +DLP API from PHP. |
| 7 | + |
| 8 | +## Build and Run |
| 9 | +1. **Enable APIs** - [Enable the DLP API]( |
| 10 | + https://console.cloud.google.com/flows/enableapi?apiid=dlp.googleapis.com) |
| 11 | + and create a new project or select an existing project. |
| 12 | +2. **Download The Credentials** - Click "Go to credentials" after enabling the APIs. Click |
| 13 | + "New Credentials" |
| 14 | + and select "Service Account Key". Create a new service account, use the JSON key type, and |
| 15 | + select "Create". Once downloaded, set the environment variable `GOOGLE_APPLICATION_CREDENTIALS` |
| 16 | + to the path of the JSON key that was downloaded. |
| 17 | +3. **Clone the repo** and cd into this directory |
| 18 | +``` |
| 19 | + $ git clone https://github.com/GoogleCloudPlatform/php-docs-samples |
| 20 | + $ cd php-docs-samples/dlp |
| 21 | +``` |
| 22 | +4. **Install dependencies** via [Composer](http://getcomposer.org/doc/00-intro.md). |
| 23 | + Run `php composer.phar install` (if composer is installed locally) or `composer install` |
| 24 | + (if composer is installed globally). |
| 25 | +5. Run `php dlp.php`. The following commands are available: |
| 26 | + |
| 27 | + ``` |
| 28 | + help Displays help for a command |
| 29 | + inspect-datastore Inspect Cloud Datastore using the Data Loss Prevention (DLP) API. |
| 30 | + inspect-file Inspect a file using the Data Loss Prevention (DLP) API. |
| 31 | + inspect-string Inspect a string using the Data Loss Prevention (DLP) API. |
| 32 | + list Lists commands |
| 33 | + list-categories Lists all Info Type Categories for the Data Loss Prevention (DLP) API. |
| 34 | + list-info-types Lists all Info Types for the Data Loss Prevention (DLP) API. |
| 35 | + redact-string Redact sensitive data from a string using the Data Loss Prevention (DLP) API. |
| 36 | + ``` |
| 37 | +
|
| 38 | + Example: |
| 39 | +
|
| 40 | + ``` |
| 41 | + $ php dlp.php inspect-string 'Robert Frost' |
| 42 | + Findings: |
| 43 | + Quote: Robert |
| 44 | + Info type: US_MALE_NAME |
| 45 | + Likelihood: Very likely |
| 46 | + ``` |
| 47 | +
|
| 48 | +
|
| 49 | +6. Run `php dlp.php COMMAND --help` to print information about the usage of each command. |
| 50 | +
|
| 51 | +## Contributing changes |
| 52 | +
|
| 53 | +* See [CONTRIBUTING.md](../../CONTRIBUTING.md) |
| 54 | +
|
| 55 | +## Licensing |
| 56 | +
|
| 57 | +* See [LICENSE](../../LICENSE) |
0 commit comments