Install PHP SDK

You can find the latest version on our github Repository:

Install PHP SDK using composer

composer require switchover/php-sdk

and import it into your project:

require __DIR__ . '/vendor/autoload.php';

use Switchover\SwitchoverClient;
use Switchover\Context;

Initialize client

You will find your SDK Key on the environment page. Copy it and use it to initialize the client:

Basic usage:

// create a client, per default the client will cache the toggles 60 seconds
$client = new SwitchoverClient('<SDK-KEY');

//get some toggle values
$featureValue = $client->toggleValue('<TOGGLE-NAME>', false);

//or with context if you have specific (user) conditions
$context = new Context(array('email' => ''));

$isFeatureVisible = $client->toggleValue('<OTHER-FLAG>', false, $context);

if ($isFeatureVisible) {
    // something

Of course it’s also possible to add some Options to the client:

$client = new SwitchoverClient('<SDK-KEY', [
    'cache.time' => 10,
    'http' => [
        'timeout' => '10',
        'proxy' => 'http://proxy.tld'


cache.timeSets time in seconds before the internal cache becomes stale and will be refreshed (TTL). Default is 60 seconds. The value 0 will keep the cache forever.
loggerPossibility to provide you own logger instance (PSR-7).
cacheOption to set your cache instance (e.g. for redis). Expects a PSR-16 compliant instance.
httpThe client uses guzzlehttp/guzzle for http requests. You can pass an array of options to the Guzzle Http Client.

Context Object

To check conditions in the client sdk a context object must be created and passed to the toggleValue method.

$contextArray = array("key" => "value");
$context = new Context($contextArray);

Public methods


namethe name of the feature toggle configured in switchover
defaultValueIt will return the given default value:
* – When toggle is INACTIVE
* – When evalution fails
* – When client was not fully initialized
contextContext Object (array)
    string $name, 
    boolean $defaultValue, 
    Context $context = null


Manually refreshes toggles.



Get all toggle keys, which currently loaded