You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLIENT_CONFIGURATION.md
+57-38Lines changed: 57 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,35 +2,12 @@
2
2
3
3
The Google Cloud PHP Client Libraries (built on `google/gax` and `google/cloud-core`) allow you to configure client behavior via an associative array passed to the client constructor. This array is processed by the [`Google\ApiCore\ClientOptions`](https://docs.cloud.google.com/php/docs/reference/gax/latest/Options.ClientOptions) class.
4
4
5
-
## Common Configuration Options
5
+
## 1. Customizing the API Endpoint
6
6
7
-
The following options can be passed to the constructor of any generated client (e.g., `PubSubClient`, `SpannerClient`, `StorageClient`).
7
+
You can modify the API endpoint to connect to a specific Google Cloud region (to reduce latency or
8
+
meet data residency requirements) or to a private endpoint (via Private Service Connect).
8
9
9
-
| Option Key | Type | Description |
10
-
| ----- | ----- | ----- |
11
-
|`credentials`|`string`|`array`|
12
-
|`apiKey`|`string`| An **API Key** for services that support public API key authentication (bypassing OAuth2). |
13
-
|`apiEndpoint`|`string`| The address of the API remote host. specific for **Regional Endpoints** (e.g., `us-central1-pubsub.googleapis.com:443`) or Private Service Connect. |
14
-
|`transport`|`string`| Specifies the transport type. Options: `'grpc'` (default), `'rest'`, or `'grpc-fallback'`. |
15
-
|`transportConfig`|`array`| Configuration specific to the transport, such as gRPC channel arguments. |
16
-
|`disableRetries`|`bool`| If `true`, disables the default retry logic for all methods in the client. |
17
-
|`logger`|`Psr\Log\LoggerInterface`| A PSR-3 compliant logger for client-level logging and tracing. |
18
-
|`universeDomain`|`string`| Overrides the default service domain (defaults to `googleapis.com`) for Cloud Universe support. |
19
-
20
-
## 1\. Authentication Configuration
21
-
22
-
While the client attempts to find "Application Default Credentials" automatically, you can explicitly provide them using
23
-
the `credentials` or `apiKey` options. See [`Authentication`][authentication.md] for details and examples.
You can modify the API endpoint to connect to a specific Google Cloud region (to reduce latency or meet data residency requirements) or to a private endpoint (via Private Service Connect).
30
-
31
-
### Connecting to a Regional Endpoint
32
-
33
-
Some services, like Pub/Sub and Spanner, offer regional endpoints.
10
+
Some services, like Pub/Sub and Spanner, offer **regional endpoints**:
34
11
35
12
```php
36
13
use Google\Cloud\PubSub\PubSubClient;
@@ -41,13 +18,29 @@ $pubsub = new PubSubClient([
41
18
]);
42
19
```
43
20
44
-
## 3\. Configuring a Proxy
21
+
## 2. Authentication Configuration
22
+
23
+
While the client attempts to find [Application Default Credentials][adc] automatically, you can
24
+
explicitly provide them using the `credentials` or `apiKey` options. See
25
+
[`Authentication`][authentication.md] for details and examples.
Logging can be enabled using environment variables, but you can provide an explicit PSR-3 logger
33
+
using the `logger` option. See [Troubleshooting](DEBUG.md) for a comprehensive guide.
34
+
35
+
## 3. Configuring a Proxy
45
36
46
37
The configuration method depends on whether you are using the `grpc` (default) or `rest` transport.
47
38
48
39
### Proxy with gRPC
49
40
50
-
When using the gRPC transport, the client library respects the [standard environment variables](https://grpc.github.io/grpc/php/md_doc_environment_variables.html). You **do not** need to configure this in the PHP code itself.
41
+
When using the gRPC transport, the client library respects the
**Handling Self-Signed Certificates (gRPC):** If your proxy uses a self-signed certificate (Deep Packet Inspection), you cannot simply "ignore" verification in gRPC. You must provide the path to the proxy's CA certificate bundle.
52
+
**Handling Self-Signed Certificates (gRPC):** If your proxy uses a self-signed certificate
53
+
(Deep Packet Inspection), you cannot simply "ignore" verification in gRPC. You must provide the path
54
+
to the proxy's CA certificate bundle.
60
55
61
56
```
62
57
# Point gRPC to a CA bundle that includes your proxy's certificate
If you are forcing the `rest` transport (or using a library that only supports REST), you must configure the proxy via the `transportConfig` option. This passes the settings down to the underlying Guzzle client.
63
+
If you are forcing the `rest` transport (or using a library that only supports REST), you must
64
+
configure the proxy via the `transportConfig` option. This passes the settings down to the
65
+
underlying Guzzle client.
69
66
70
67
```php
71
68
use Google\Auth\HttpHandler\HttpHandlerFactory;
@@ -84,17 +81,20 @@ $secretManagerClient = new SecretManagerServiceClient([
84
81
]);
85
82
```
86
83
87
-
## 4\. Configuring Retries and Timeouts
84
+
## 4. Configuring Retries and Timeouts
88
85
89
-
There are two ways to configure retries and timeouts: global client configuration (complex) and per-call configuration (simple).
86
+
There are two ways to configure retries and timeouts: global client configuration (complex) and
87
+
per-call configuration (simple).
90
88
91
89
### Per-Call Configuration (Recommended)
92
90
93
-
For most use cases, it is cleaner to override settings for specific calls using `Google\ApiCore\Options\CallOptions` (or the `$optionalArgs` array in generated clients).
91
+
For most use cases, it is cleaner to override settings for specific calls using
92
+
`Google\ApiCore\Options\CallOptions` (or the `$optionalArgs` array in generated clients).
94
93
95
94
#### Available `retrySettings` Keys
96
95
97
-
When passing an array to `retrySettings`, you can use the following keys to fine-tune the exponential backoff strategy:
96
+
When passing an array to `retrySettings`, you can use the following keys to fine-tune the
You can also configure retries globally by passing a `clientConfig` array to the constructor. This is useful if you want to change the default retry strategy for *all* calls made by that client instance.
128
+
You can also configure retries globally by passing a `clientConfig` array to the constructor.
129
+
This is useful if you want to change the default retry strategy for *all* calls made by that client
130
+
instance.
129
131
130
132
```php
131
133
use Google\Cloud\PubSub\PubSubClient;
@@ -136,9 +138,11 @@ $pubsub = new PubSubClient([
136
138
]);
137
139
```
138
140
139
-
## 5\. Logging
141
+
## 5. Logging
140
142
141
-
You can attach any PSR-3 compliant logger (like Monolog) to debug request headers, status codes, and payloads. See [Debug Logging](https://docs.cloud.google.com/php/docs/reference/help/debug) for more examples.
143
+
You can attach any PSR-3 compliant logger (like Monolog) to debug request headers, status codes, and
144
+
payloads. See [Debug Logging](https://docs.cloud.google.com/php/docs/reference/help/debug) for more
145
+
examples.
142
146
143
147
```php
144
148
use Google\Cloud\PubSub\PubSubClient;
@@ -153,3 +157,18 @@ $client = new PubSubClient([
153
157
]);
154
158
```
155
159
160
+
## 6. Other Common Configuration Options
161
+
162
+
The following options can be passed to the constructor of any generated client (e.g.,`PubSubClient`,
163
+
`SpannerClient`, `StorageClient`).
164
+
165
+
| Option Key | Type | Description |
166
+
| ----- | ----- | ----- |
167
+
|`credentials`|`string`|`array`|
168
+
|`apiKey`|`string`| An **API Key** for services that support public API key authentication (bypassing OAuth2). |
169
+
|`apiEndpoint`|`string`| The address of the API remote host. specific for **Regional Endpoints** (e.g., `us-central1-pubsub.googleapis.com:443`) or Private Service Connect. |
170
+
|`transport`|`string`| Specifies the transport type. Options: `'grpc'` (default), `'rest'`, or `'grpc-fallback'`. |
171
+
|`transportConfig`|`array`| Configuration specific to the transport, such as gRPC channel arguments. |
172
+
|`disableRetries`|`bool`| If `true`, disables the default retry logic for all methods in the client. |
173
+
|`logger`|`Psr\Log\LoggerInterface`| A PSR-3 compliant logger for client-level logging and tracing. |
174
+
|`universeDomain`|`string`| Overrides the default service domain (defaults to `googleapis.com`) for Cloud Universe support. |
0 commit comments