1. Go to this page and download the library: Download vehikl/flip 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/ */
vehikl / flip example snippets
class SomeFeature extends \Vehikl\Flip\Feature
{
// Decides under which conditions this Feature is enabled
*/
public function enabled()
{
return random_int(0, 1) == 1;
}
/**
* Returns an array of available toggles for this feature
*/
public function toggles()
{
return [
'someToggle' => [
'on' => 'whenOn',
'off' => 'whenOff'
]
];
}
public function whenOn()
{
return "I'm on!";
}
public function whenOff()
{
return "I'm off!";
}
}
class SomeClass
{
use Vehikl\Flip\Featurable;
protected $features = [SomeFeature::class];
public function someBehaviour()
{
// no need for if/else blocks, just call the toggle using the
// `flip` helper
return $this->flip()->someToggle();
}
}
// force the SomeFeature feature to be always on
SomeFeature::alwaysOn()
// anytime `someToggle` is called on instances of SomeClass,
// the `on` version of `someToggle` will be run
$someObject = new SomeClass;
$someObject->someBehaviour(); // always returns "I'm on!"
php
class SomeFeature extends \Vehikl\Flip\Feature
{
/**
* Decides under which conditions this Feature is enabled
*/
public function enabled()
{
return random_int(0, 1) == 1;
}
/**
* Returns an array of available toggles for this feature
*/
public function toggles()
{
return [
'someToggle' => [
'on' => 'whenOn',
'off' => 'whenOff'
]
];
}
public function whenOn()
{
return "I'm on!";
}
public function whenOff()
{
return "I'm off!";
}
}
class SomeClass
{
use Vehikl\Flip\Featurable;
protected $features = [SomeFeature::class];
public function someBehaviour()
{
// no need for if/else blocks, just call the toggle using the
// `flip` helper
return $this->flip()->someToggle();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.