-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path10-timeout.php
37 lines (32 loc) · 932 Bytes
/
10-timeout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use GuzzleHttp\Client;
use GuzzleHttp\RequestOptions;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\HttpClient\Psr18Client;
use Unleash\Client\UnleashBuilder;
require __DIR__ . '/_common.php';
if (class_exists(Client::class)) {
$httpClient = new Client([
RequestOptions::TIMEOUT => 2,
]);
} else if (class_exists(Psr18Client::class)) {
$httpClient = HttpClient::create([
'timeout' => 2,
]);
$httpClient = new Psr18Client($httpClient);
} else {
throw new LogicException('No supported http client (for this example) found');
}
$unleash = UnleashBuilder::create()
->withAppName($appName)
->withAppUrl($appUrl)
->withInstanceId($instanceId)
->withHttpClient($httpClient)
->withHeader('Authorization', $apiKey)
->build()
;
if ($unleash->isEnabled('myFeature')) {
echo "myFeature is enabled";
} else {
echo "myFeature is disabled";
}