PHPackages                             vehikl/flip - 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. vehikl/flip

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

vehikl/flip
===========

A Feature Toggle implementation

0.2.0(7y ago)77.0k2MITPHPPHP ^7.1

Since Jun 16Pushed 7y ago28 watchersCompare

[ Source](https://github.com/vehikl/flip)[ Packagist](https://packagist.org/packages/vehikl/flip)[ Docs](https://github.com/vehikl/flip)[ RSS](/packages/vehikl-flip/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

Flip
====

[](#flip)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b162c56761f1ec172084c7b2bb4687518324d66ecc107cb39c2b543822cc2e7a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766568696b6c2f666c69702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vehikl/flip)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/cedffa9bce2a73c8c52ea94c06d865eb217e39aa6928dfd7c2c7b98b4cb599fa/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f766568696b6c2f666c69702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/vehikl/flip)[![Coverage Status](https://camo.githubusercontent.com/32f54e5c9ee478fa153b89cf84abb12bfe7cbaa6cd1e14315dad580477abd7ec/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f766568696b6c2f666c69702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vehikl/flip/code-structure)[![Quality Score](https://camo.githubusercontent.com/7b120a6c93a7e798c24202eafd75c8a22a567e65f9e31cc6c64d95ddfa5c8a91/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f766568696b6c2f666c69702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/vehikl/flip)[![Total Downloads](https://camo.githubusercontent.com/1a0bba727fd93986138ac4333fd866c4c89039a04b5f576136dd9057d895f87f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f766568696b6c2f666c69702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/vehikl/flip)

Flip is a simple Feature Toggle implementation. Features are implemented as independent classes and are "mixed" into the class you want the feature to be exposed from.

Install
-------

[](#install)

Via Composer

```
$ composer require vehikl/flip
```

Usage
-----

[](#usage)

A Flip feature is just a regular PHP class with a few required methods.

`enabled` - This method returns a boolean value indicating if the feature is enabled or not

`toggles` - This method returns an array of available feature toggles. The array is keyed by the name of the method which is called to run the feature. The value of each key is an associative array with keys `on` and `off`, each key is mapped to the appropriate method to call depending on if the feature is "on" or "off".

```
class SomeFeature extends \Vehikl\Flip\Feature
{
    /**
     * Decides under which conditions this Feature is enabled
     */
    public function enabled()
    {
        return random_int(0, 1) == 1;
    }

    /**
     * Returns an array of available toggles for this feature
     */
    public function toggles()
    {
        return [
            'someToggle' => [
                'on' => 'whenOn',
                'off' => 'whenOff'
            ]
        ];
    }

    public function whenOn()
    {
        return "I'm on!";
    }

    public function whenOff()
    {
        return "I'm off!";
    }
}

class SomeClass
{
    use Vehikl\Flip\Featurable;

    protected $features = [SomeFeature::class];

    public function someBehaviour()
    {
        // no need for if/else blocks, just call the toggle using the
        // `flip` helper
        return $this->flip()->someToggle();
    }
}
```

### Forcing Features to be On or Off

[](#forcing-features-to-be-on-or-off)

You can force a feature to be "on" or "off" by calling the `alwaysOn` or `alwaysOff` static methods respectively. This will force all features of that class to be either "on" or "off" regardless of how their `enabled` methods evaluate.

```
class SomeFeature extends \Vehikl\Flip\Feature
{
    // include the $forcedState static variable if you want to enable forcing state
    protected static $forcedState;

    /**
     * Decides under which conditions this Feature is enabled
     */
    public function enabled()
    {
        return random_int(0, 1) == 1;
    }

    /**
     * Returns an array of available toggles for this feature
     */
    public function toggles()
    {
        return [
            'someToggle' => [
                'on' => 'whenOn',
                'off' => 'whenOff'
            ]
        ];
    }

    public function whenOn()
    {
        return "I'm on!";
    }

    public function whenOff()
    {
        return "I'm off!";
    }
}

class SomeClass
{
    use Vehikl\Flip\Featurable;

    protected $features = [SomeFeature::class];

    public function someBehaviour()
    {
        // no need for if/else blocks, just call the toggle using the
        // `flip` helper
        return $this->flip()->someToggle();
    }
}

// force the SomeFeature feature to be always on
SomeFeature::alwaysOn()

// anytime `someToggle` is called on instances of SomeClass,
// the `on` version of `someToggle` will be run
$someObject = new SomeClass;
$someObject->someBehaviour();  // always returns "I'm on!"
```

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Colin DeCarlo](https://github.com/colindecarlo)
- [Brad Brothers](https://github.com/bbrothers)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.4% 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.

###  Release Activity

Cadence

Every ~29 days

Total

4

Last Release

2847d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/682860?v=4)[Colin DeCarlo](/maintainers/colindecarlo)[@colindecarlo](https://github.com/colindecarlo)

![](https://www.gravatar.com/avatar/e28022d3c3464a3709a9dc203329e92346c5bd34891e433712ed310c9bef781a?d=identicon)[mrozbarry](/maintainers/mrozbarry)

![](https://avatars.githubusercontent.com/u/83667?v=4)[Grant Lovell](/maintainers/GrantLovell)[@grantlovell](https://github.com/grantlovell)

![](https://avatars.githubusercontent.com/u/2477338?v=4)[Brad](/maintainers/bbrothers)[@bbrothers](https://github.com/bbrothers)

---

Top Contributors

[![colindecarlo](https://avatars.githubusercontent.com/u/682860?v=4)](https://github.com/colindecarlo "colindecarlo (37 commits)")[![bbrothers](https://avatars.githubusercontent.com/u/2477338?v=4)](https://github.com/bbrothers "bbrothers (1 commits)")

---

Tags

featurefeature togglevehikl

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/vehikl-flip/health.svg)

```
[![Health](https://phpackages.com/badges/vehikl-flip/health.svg)](https://phpackages.com/packages/vehikl-flip)
```

###  Alternatives

[qandidate/toggle

Feature toggling for your PHP application.

3792.0M9](/packages/qandidate-toggle)[flagception/flagception-bundle

Feature toggle bundle on steroids.

294.0M](/packages/flagception-flagception-bundle)[opensoft/rollout

Feature switches or flags for PHP

2571.9M5](/packages/opensoft-rollout)[zumba/swivel

Strategy driven feature toggles

208138.1k5](/packages/zumba-swivel)[novaway/feature-flag-bundle

Very KISS bundle to manage features flag

24287.1k](/packages/novaway-feature-flag-bundle)[codinglabsau/laravel-feature-flags

Dynamic feature flags for laravel.

3884.7k](/packages/codinglabsau-laravel-feature-flags)

PHPackages © 2026

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