1. Go to this page and download the library: Download mileschou/toggle-simplify 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/ */
mileschou / toggle-simplify example snippets
$toggle = new Toggle();
$toggle->create('f1', true);
// Will return true
$toggle->isActive('f1');
$toggle = new Toggle();
$toggle->create('f1', function() {
return true;
});
// Will return true
$toggle->isActive('f1');
$toggle = new Toggle();
$toggle->create('f1', function($context) {
return $context['default'];
});
// Will return true
$toggle->isActive('f1', [
'return' => true,
]);
$toggle = new Toggle();
$toggle->create('f1', true, ['name' => 'Miles']);
$toggle->create('f2', false, ['name' => 'Chou']);
// Will return 'Chou'
$toggle->params('f1', 'name');
// Also using in callback
$toggle->create('f3', function($context, array $params) {
return $params['key'] === $context['key'];
}, ['key' => 'foo']);
$toggle = new Toggle();
$toggle->create('f1');
$toggle->create('f2');
$toggle->create('f3');
$toggle
->when('f1', function ($context, $params) {
// Something when f1 is on
})
->when('f2', function ($context, $params) {
// Something when f2 is on
})
->when('f3', function ($context, $params) {
// Something when f3 is on
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.