See More

> For the complete documentation index, see [llms.txt](https://docs.sonsofphp.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonsofphp.com/components/feature-toggle.md). # Feature Toggle ## Installation ```shell composer require sonsofphp/feature-toggle ``` ## Usage ```php add(new Feature('feature.example', new AlwaysEnabledToggle())); $feature = $provider->get('feature.example'); // Checking if the feature is enabled $isEnabled = $feature->isEnabled(); ``` ### Advanced Usage ```php $user, ]); $context->set('user', $user); $context['user'] = $user; $isEnabled = $feature->isEnabled($context); ``` When you create your own toggles, you may need to introduce additional context to the toggle to check if everything should be enabled or disabled. This is where this comes into play at. #### Chain Toggle The chain toggle allows you to use many toggles together. If ANY toggle returns `true`, the feature is considered enabled. ```php isEnabled(); ``` #### Affirmative Toggle Similar to the chain toggle, this will only return `true` when ALL toggles are `true`. ```php isEnabled(); ``` #### Date Range Toggle The date range toggle will return `true` if it's within a given time range. ```php