1. Go to this page and download the library: Download yannickl88/features-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/ */
yannickl88 / features-bundle example snippets
// app/AppKernel.php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Yannickl88\FeaturesBundle\FeaturesBundle(),
// …
];
}
}
namespace App\Feature;
use Symfony\Component\HttpFoundation\RequestStack;
use Yannickl88\FeaturesBundle\Feature\FeatureResolverInterface;
class RequestResolver implements FeatureResolverInterface
{
private $request_stack;
public function __construct(RequestStack $request_stack)
{
$this->request_stack = $request_stack;
}
/**
* {@inheritdoc}
*/
public function isActive(array $options = []): bool
{
// Feature is inactive when there is no request
if (null === $request = $this->request_stack->getMasterRequest()) {
return false;
}
// $options contains ["beta", "on"] for the 'beta' feature tag
list($key, $expected_value) = $options;
return $request->get($key) === $expected_value;
}
}
namespace App\Some;
use Yannickl88\FeaturesBundle\Feature\Feature;
class Service
{
private $feature;
public function __construct(Feature $feature)
{
$this->feature = $feature;
}
public function someMethod(): void
{
if ($this->feature->isActive()) {
// do some extra beta logic when this feature is active
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.