PHP code example of twentytwo-labs / feature-flag-bundle
1. Go to this page and download the library: Download twentytwo-labs/feature-flag-bundle 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/ */
twentytwo-labs / feature-flag-bundle example snippets
use App\Controller;
// ...
class MyController extends Controller
{
public function myAction(ChainedFeatureManager $featureManager): Response
{
if ($featureManager->isEnabled('my_feature_1')) {
// my_feature_1 is enabled
}
if ($featureManager->isDisabled('my_feature_2')) {
// my_feature_2 is not enabled
}
// ...
}
}
#[Feature(name: "foo", enabled: true)]
class MyController extends Controller
{
#[Feature(name: "foo")]
public function annotationFooEnabledAction(): Response
{
return new Response('MyController::annotationFooEnabledAction');
}
#[Feature(name: "foo", enabled: true)]
public function annotationFooEnabledBisAction(): Response
{
return new Response('MyController::annotationFooEnabledAction');
}
#[Feature(name: "foo", enabled: false)]
public function annotationFooDisabledAction(): Response
{
return new Response('MyController::annotationFooDisabledAction');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.