PHPackages                             bazo/feature-toggler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bazo/feature-toggler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bazo/feature-toggler
====================

Feature toggling library for php

811.5k↑18.2%1PHP

Since Jul 7Pushed 9y ago1 watchersCompare

[ Source](https://github.com/bazo/feature-toggler)[ Packagist](https://packagist.org/packages/bazo/feature-toggler)[ RSS](/packages/bazo-feature-toggler/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

feature-toggler
===============

[](#feature-toggler)

Feature toggling library for php

usage:

```
$toggler = new Toggler($config);
if($toggler->enabled('featureName')) {
	...
}

```

you can also pass context to toggler:

```
$toggler = new Toggler($config);

$context = [
	'userId' => 150,
	'site' => 'sk'

];
//using only globals
if($toggler->enabled('feature1')) { //true
	...
}

or
//using globals and local context
if($toggler->enabled('feature1', $context)) { //true
	...
}

```

configuration:

simple, with an array

```
$config = [
		'globals' => [
			'site'=> 'sk'
		],
		'feature1' => [
			'conditions' => [
				['field' => 'site', 'operator' => 'in', 'arg' => ['sk', 'cz']],
				['field' => 'userId', 'operator' => '>', 'arg' => 140]
		],
		'paypal' => [
			'conditions' => [
				['field' => 'site', 'operator' => 'in', 'arg' => ['sk', 'cz', 'de', 'at']]
			]
		]
];

```

or you can use use shorthand syntax for conditions, it's much cleaner and more readable

```
['site', 'in', ['sk', 'cz', 'de', 'at']]

```

Operators:

there's 5 built-in operators, that cannot be overriden: &gt; - value must be greater than arg &lt; - value must be lower than arg = - value must be equal than arg in - value must be in set of args notIn - value must not be in set of args

You can also register custom operators. A custom operator must implement IOperator interface

```
$operator = new MyCustomOperator;
$toggler->registerOperator($operator);

```

you can also override the default operator sign

```
$toggler->registerOperator($operator, 'myCustomSign');

```

then you write a condition like this

```
['field' => 'site', 'operator' => 'myCustomSign', 'arg' => [1, 2, 3, ...]]

```

Custom features backend:

You can also a custom backend for storing features and their conditions, for example a database

The backend needs to implement **IFeaturesBackend** interface which has one method: **getConfig()**

then you use it like this

```
$backend = new MyRedisBackend(...);
$toggler = new BackendDrivenToggler($backend)

```

enjoy!

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8e88095e75ebabe4a1ace0bf87ec2813e6182f2ee80ac025f8e5bc5e00917b4f?d=identicon)[bazo](/maintainers/bazo)

---

Top Contributors

[![bazo](https://avatars.githubusercontent.com/u/181588?v=4)](https://github.com/bazo "bazo (18 commits)")

### Embed Badge

![Health badge](/badges/bazo-feature-toggler/health.svg)

```
[![Health](https://phpackages.com/badges/bazo-feature-toggler/health.svg)](https://phpackages.com/packages/bazo-feature-toggler)
```

###  Alternatives

[roukmoute/hashids-bundle

Integrates hashids/hashids in a Symfony project

46332.0k1](/packages/roukmoute-hashids-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
