featuretoggle/lib-php

PHP Library to use Feature Toggle services

v1.0.1 2016-09-11 20:10 UTC

This package is not auto-updated.

Last update: 2024-04-13 16:46:04 UTC


README

A PHP client library for interacting with featuretoggle.com. This library is under active development and is likely to change frequently. Bug reports and pull requests are welcome.

Installation

Install with Composer

php composer.phar require featuretoggle/lib-php

Usage

require 'vendor/autoload.php';

// Create a new FTClient with your customer and environment API key's
$featuretoggle = new FeatureToggle\FTClient('customerKey', 'environmentKey', array('options'));

// Get features
$features = $featuretoggle->getFeatures();

// Check feature status
$enabled = $featuretoggle->isEnabled('feature_key');
if($enabled) {
    // Feature is enabled, do something
}
else {
    // Feature is disabled, do something else
}

Configuration Options

The library caches responses from received the Feature Toggle API locally to limit the number of requests. The default cache timeout is 300 seconds (5 minutes). You can adjust the cache timeout by providing the 'cache_timeout' config option when initializing the library.

array(
    'cache_timeout' => SECONDS, // optional, defaults to 300 seconds
)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/featuretoggle/lib-php.

License

The library is available as open source under the terms of the MIT License.