PHP code example of open-feature / split-provider

1. Go to this page and download the library: Download open-feature/split-provider 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/ */

    

open-feature / split-provider example snippets


$splitConfig = [
    'cache' => [
      'adapter' => 'predis',
      'parameters' => [
        'scheme' => 'tcp',
        'host' => getenv('REDIS_HOST'),
        'port' => getenv('REDIS_PORT'),
        'timeout' => 881,
      ],
      'options' => [
        'prefix' => '',
      ],
    ],
];

$splitApiKey = getenv('SPLIT_API_KEY');

$provider = new SplitProvider($splitApiKey, $splitConfig);

$client = $api->getClient('split-example', '1.0.0');

$featureEnabled = $client->getBooleanDetails('dev.openfeature.example_flag', false, new EvaluationContext('user-id'), null);

if ($featureEnabled) {
  // do new logic here
} else {
  // do old logic here
}

$client = $api->getClient('split-example', '1.0.0');

$featureEnabled = $client->getBooleanDetails('dev.openfeature.example_flag', false, new EvaluationContext('user-id', [
  'plan_type' => 'growth',
  'registered_date' => (new DateTime('now', new DateTimeZone('UTC')))->getTimestamp(),
  'deal_size' => 10000,
  'paying_customer' => True,
  'permissions' => ['gold','silver','platinum'],
]), null);

if ($featureEnabled) {
  // do new logic here
} else {
  // do old logic here
}