1. Go to this page and download the library: Download ssola/enabler 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/ */
ssola / enabler example snippets
$feature = new Enabler\Feature(
'secret-feature',
true,
[
'Enabler\Filter\Distributed' => [1]
]
);
$enabler = new Enabler\Enabler($storage);
$enabler->storage()->create($feature);
// At this point feature has been created and will use the Distributed filter to display it only to 1% of our visitors
// after this we can create the condition:
if ($enabler->enabled('secret-feature')) {
// Here your feature for only 1% of your visitors.
}
$identity = new Enabler\Identity(MyUserClass::getUserId(), MyUserClass::getGroup());
$feature = new Enabler\Feature(
'secret-feature',
true,
[
'Enabler\Filter\Identifier' => ['groups' => ['early-adopters', 'test-users']]
]
);
$enabler = new Enabler\Enabler($storage, $identity);
$enabler->storage()->create($feature);
if ($enabler->enabled('secret-feature')) {
// Here your feature for users that belongs to early-adopters or test-users group
}
$identity = new Enabler\Identity(MyUserClass::getUserId(), MyUserClass::getGroup());
$feature = new Enabler\Feature(
'secret-feature',
true,
[
'Enabler\Filter\Distributed' => [10],
'Enabler\Filter\Identifier' => ['groups' => ['test-users']],
'Enabler\Filter\Date' => ['from' => new DateTime('2014-10-30'), 'to' => new DateTime('2015-10-30')]
]
);
$enabler = new Enabler\Enabler($storage, $identity);
$enabler->storage()->create($feature);
if ($enabler->enabled('secret-feature')) {
// Here your feature for users that belongs to early-adopters or test-users group
}
class MyAwesomeStorageAdapter implements Enabler\Storage\Storable
{
public function create (Feature $feature) {
// do your magic here!
}
public function delete ($name) {
// delete a specific Feature
}
public function get ($name) {
return $myFeature;
}
}
class FilterByWeather implements Enabler\Filter\Filterable
{
public function filter ($value, Feature $feature, Identity $identity) {
// our value is Sunny
$currentWeather = Weather::getFromIp(IP::getIp());
if($currentWeather == $value) {
return true;
}
return false;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.