Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require syzygypl/kunstmaan-feature-switches-bundleThis command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new SZG\KunstmaanFeatureSwitchesBundle\KunstmaanFeatureSwitchesBundle(),
);
// ...
}
// ...
}bin/console doctrine:migration:diff
bin/console doctrine:migration:migrate
// app/config/routing.yml
KunstmaanFeatureSwitchesBundle:
resource: "@KunstmaanFeatureSwitchesBundle/Resources/config/routing.yml"
prefix: /{_locale}/admin/
requirements:
_locale: "%requiredlocales%"Just enter the /{locale}/admin/settings and select "Feature switches" from the sidebar menu. Then use a big blue button in the right top cornenr. Name and code have to be unique.
{% if is_granted('my_special_feature', 'features') %} ENABLED {% endif %}In a controller:
/// ...
$this->denyAccessUnlessGranted('my_special_feature', 'features');
// ...Create a new file: app/Features.php
// app/Features.php
<?php
class Features
{
const MY_SPECIAL = 'my_special_feature';
}Require just created file in autoloader:
// app/autoload.php
// ...
require __DIR__.'/Features.php';
// ...Now you can use constants in twig:
{% if is_granted(constant(Features::MY_SPECIAL), 'features') %} ENABLED {% endif %}