1. Go to this page and download the library: Download xepozz/feature-flag 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/ */
\Xepozz\FeatureFlag\Driver\RedisDriver::class => function () {
$redis = new Redis();
$redis->pconnect(
host: '127.0.0.1',
port: 6379,
timeout: 2.5,
);
return new \Xepozz\FeatureFlag\Driver\RedisDriver(redis: $redis, hashTableKey: 'ab');
},
use Xepozz\FeatureFlag\FlagStorageInterface;
use \Xepozz\FeatureFlag\Driver\RedisDriver;
return [
// ...
FlagStorageInterface::class => RedisDriver::class,
// ...
]
use Xepozz\FeatureFlag\FlagStorageInterface;
class Controller
{
public function index(FlagStorageInterface $flagStorage)
{
if ($flagStorage->isActive('feature_name')) {
// feature is enabled
} else {
// feature is disabled
}
}
}
use Xepozz\FeatureFlag\FlagStorageInterface;
class Controller
{
public function index(FlagStorageInterface $flagStorage)
{
if ($condition) {
$flagStorage->setFlag('feature_name', true);
}
}
}
use Xepozz\FeatureFlag\FlagStorageInterface;
class Controller
{
public function index(FlagStorageInterface $flagStorage)
{
$flags = $flagStorage->getAll();
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.