Skip to content

Commit 28a8173

Browse files
authored
Update README.md
1 parent 28401e1 commit 28a8173

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ or:
7171
<?php
7272

7373
use YdbPlatform\Ydb\Ydb;
74-
use YdbPlatform\Ydb\Auth\AccessTokenAuthentication;
74+
use YdbPlatform\Ydb\Auth\Implement\AccessTokenAuthentication;
7575

7676
$config = [
7777

@@ -134,7 +134,7 @@ or
134134
<?php
135135

136136
use YdbPlatform\Ydb\Ydb;
137-
use YdbPlatform\Ydb\Auth\OAuthTokenAuthentication;
137+
use YdbPlatform\Ydb\Auth\Implement\OAuthTokenAuthentication;
138138

139139
$config = [
140140

@@ -192,7 +192,7 @@ or
192192
<?php
193193

194194
use YdbPlatform\Ydb\Ydb;
195-
use YdbPlatform\Ydb\Auth\JwtWithPrivateKeyAuthentication;
195+
use YdbPlatform\Ydb\Auth\Implement\JwtWithPrivateKeyAuthentication;
196196

197197
$config = [
198198
'database' => '/ru-central1/b1glxxxxxxxxxxxxxxxx/etn0xxxxxxxxxxxxxxxx',
@@ -249,7 +249,7 @@ or:
249249
<?php
250250

251251
use YdbPlatform\Ydb\Ydb;
252-
use YdbPlatform\Ydb\Auth\JwtWithJsonAuthentication;
252+
use YdbPlatform\Ydb\Auth\Implement\JwtWithJsonAuthentication;
253253

254254
$config = [
255255
'database' => '/ru-central1/b1glxxxxxxxxxxxxxxxx/etn0xxxxxxxxxxxxxxxx',
@@ -299,7 +299,7 @@ or
299299
<?php
300300

301301
use YdbPlatform\Ydb\Ydb;
302-
use YdbPlatform\Ydb\Auth\MetadataAuthentication;
302+
use YdbPlatform\Ydb\Auth\Implement\MetadataAuthentication;
303303

304304
$config = [
305305

@@ -355,7 +355,7 @@ or:
355355
<?php
356356

357357
use YdbPlatform\Ydb\Ydb;
358-
use YdbPlatform\Ydb\Auth\AnonymousAuthentication;
358+
use YdbPlatform\Ydb\Auth\Implement\AnonymousAuthentication;
359359

360360
$config = [
361361

@@ -379,6 +379,44 @@ $config = [
379379
$ydb = new Ydb($config);
380380
```
381381

382+
## Determined by environment variables
383+
384+
```php
385+
<?php
386+
387+
use YdbPlatform\Ydb\Ydb;
388+
use YdbPlatform\Ydb\Auth\Implement\EnvironCredentials;
389+
390+
$config = [
391+
392+
// Database path
393+
'database' => '/local',
394+
395+
// Database endpoint
396+
'endpoint' => 'localhost:2136',
397+
398+
// Auto discovery (dedicated server only)
399+
'discovery' => false,
400+
401+
// IAM config
402+
'iam_config' => [
403+
'insecure' => true,
404+
],
405+
406+
'credentials' => new EnvironCredentials()
407+
];
408+
409+
$ydb = new Ydb($config);
410+
```
411+
412+
The following algorithm that is the same for YDB-PHP-SDK applies:
413+
414+
1. If the value of the `YDB_SERVICE_ACCOUNT_KEY_FILE_CREDENTIALS` environment variable is set, the **System Account Key** authentication mode is used and the key is taken from the file whose name is specified in this variable.
415+
2. Otherwise, if the value of the `YDB_ANONYMOUS_CREDENTIALS` environment variable is set to 1, the anonymous authentication mode is used.
416+
3. Otherwise, if the value of the `YDB_METADATA_CREDENTIALS` environment variable is set to 1, the **Metadata** authentication mode is used.
417+
4. Otherwise, if the value of the `YDB_ACCESS_TOKEN_CREDENTIALS` environment variable is set, the **Access token** authentication mode is used, where the this variable value is passed.
418+
5. Otherwise, the **Metadata** authentication mode is used.
419+
382420
# Usage
383421

384422
You should initialize a session from the Table service to start querying.

0 commit comments

Comments
 (0)