1. Go to this page and download the library: Download flagdash/sdk 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/ */
flagdash / sdk example snippets
use FlagDash\Client;
$client = new Client($_ENV['FLAGDASH_SDK_KEY']);
if ($client->flag('checkout-v2', false, ['user_id' => 'alice'])) {
// new checkout
}
$client->close();
$client = new Client(
sdkKey: $_ENV['FLAGDASH_SDK_KEY'],
baseUrl: 'https://flagdash.io', // self-hosted? point it here
timeout: 5.0, // seconds per request
cacheTtl: 60.0, // seconds; 0 disables caching
region: 'eu-west-1', // omit to auto-detect
transport: new StreamTransport(),
);
// A single flag, with a fallback used whenever FlagDash cannot be reached.
$enabled = $client->flag('checkout-v2', false, ['user_id' => 'alice']);
// Every flag for this context, in one request.
$flags = $client->allFlags(['user_id' => 'alice', 'country' => 'GB']);
// Why did it resolve that way? (server key)
$detail = $client->flagDetail('checkout-v2', false, ['user_id' => 'alice']);
// ['value' => true, 'reason' => 'rule_match', 'variation' => 'treatment', ...]
// Flag metadata without evaluating anything (server key).
$all = $client->listFlags();