PHP code example of optimizely / optimizely-sdk

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

    

optimizely / optimizely-sdk example snippets




use Optimizely\Optimizely;

$optimizely = new Optimizely(<<DATAFILE>>);



use Optimizely\OptimizelyFactory;

$optimizelyClient = OptimizelyFactory::createDefaultInstance(
    "your-sdk-key",
    <<DATAFILE>>,
    <<DATAFILE_AUTH_TOKEN>>
);



use Optimizely\Optimizely;

/** @var Optimizely $optimizelyClient */
$configManager = $optimizelyClient->configManager;



use Optimizely\Optimizely;
use Optimizely\ProjectConfigManager\HTTPProjectConfigManager;

$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
$optimizely = new Optimizely(
    <<DATAFILE>>,
    null,
    null,
    null,
    false,
    null,
    $configManager
);



use Optimizely\ProjectConfigManager\HTTPProjectConfigManager;

$configManager = new HTTPProjectConfigManager(<<SDK_KEY>>);
bash
php composer.phar