PHPackages                             partechgss/laravel-feature-toggle - 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. partechgss/laravel-feature-toggle

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

partechgss/laravel-feature-toggle
=================================

Laravel Wrapper for feature toggles.

v1.0.5(5y ago)06.2k2BSD-3-Clause-ClearPHPPHP ^7.4

Since Jul 20Pushed 5y ago4 watchersCompare

[ Source](https://github.com/PartechGSS/laravel-feature-toggle)[ Packagist](https://packagist.org/packages/partechgss/laravel-feature-toggle)[ RSS](/packages/partechgss-laravel-feature-toggle/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (3)Versions (15)Used By (0)

Abstract Feature Flags from Providers
=====================================

[](#abstract-feature-flags-from-providers)

This package allows you to implement feature flags in Laravel. Right now the only supported implementation is split.io.

Basic Usage
-----------

[](#basic-usage)

### Change Behavior Based on a Flag

[](#change-behavior-based-on-a-flag)

```
use PartechGSS\Laravel\FeatureToggle\Contracts\FeatureToggleClient;

$client = resolve(FeatureToggleClient::class);
switch ($client->getTreatment('my_flag')) {
    case "on":
        do_a_thing();
        break;

    default:
        do_another_thing();
        break;
}

```

### Retrieve Configuration Attached to a Treatment

[](#retrieve-configuration-attached-to-a-treatment)

```
$treatmentWithConfig = $client->getTreatmentWithConfig('my_flag');
$treatment = $treatmentWithConfig['treatment'];
$config = $treatmentWithConfig['config'];
set_some_css_options($config);

```

### Retrieve Multiple Flags in a Batch

[](#retrieve-multiple-flags-in-a-batch)

```
$treatments = $client->getTreatments(['my_flag', 'another_flag']);
switch($treatments['my_flag']) {
    ...
}

```

### Retrieve Configurations in a Batch

[](#retrieve-configurations-in-a-batch)

```
$treatmentsWithConfig = $client->getTreatmentsWithConfig('my_flag');
$treatment = $treatmentsWithConfig['my_flag']['treatment'];
$config = $treatmentsWithConfig['my_flgag']['config'];
set_some_css_options($config);

```

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require partechgss/laravel-feature-toggles

```

Configuration
-------------

[](#configuration)

### Config File

[](#config-file)

Looks for `config/feature-toggle.php`. To install the default one:

```
php artisan vendor:publish

```

### Middleware

[](#middleware)

You need to set the toggle "key" somewhere. This is usually something like a user's email address, used to decide which treatment the user gets for a particular flag. This package provides middleware that automatically sets the key based on the user's email addesss. This must be run after your authentication middleware, so, first make it available as route middleware and set the priority in your `app/Http/Kernel.php`.

```
use PartechGSS\Laravel\FeatureToggle\Middleware\SetFeatureToggleKeyFromUserEmail;
protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'feature-toggle' => SetFeatureToggleKeyFromUserEmail::class,
];
protected $middlewarePriority = [
    \App\Http\Middleware\Authenticate::class,
    SetFeatureToggleKeyFromUserEmail::class,
];

```

#### Execute as Route Middleware

[](#execute-as-route-middleware)

```
# routes/api.php
Route::middleware(['auth:api', 'feature-toggle'])->group(function() {
    ...,
});

```

#### Execute via Route Middleware Groups

[](#execute-via-route-middleware-groups)

```
# app/Http/Kernel.php
protected $middlewareGroups = [
    'web' => [
        ...,
        'feature-toggle',
    ],

    'api' => [
        \Barryvdh\Cors\HandleCors::class,
        'throttle:60,1',
        'bindings',
        'feature-toggle',
    ],
];

```

Testing
-------

[](#testing)

### This Project

[](#this-project)

```
composer test

```

### Your Project

[](#your-project)

The SplitIO SDK throws errors when it can't find a configuration file in localhost mode. To work around that, create a dummy local `split.yaml` file and ask the factory to load it. For example, you can set SPLITIO\_SPLIT\_FILE in your testing environment to point to your file:

```
# .env.testing
SPLITIO_SPLIT_FILE=tests/__data__/split.yaml

```

This assumes a file like this one at `tests/__data__/split.yaml`:

```
- hello_world:
  treatment: off
- hello_world:
  treatment: on
  keys: "user@example.org"

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 88.5% 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 ~0 days

Total

14

Last Release

2116d ago

Major Versions

v0.1.7 → v1.0.02020-07-22

### Community

Maintainers

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

---

Top Contributors

[![derekrprice](https://avatars.githubusercontent.com/u/5413632?v=4)](https://github.com/derekrprice "derekrprice (23 commits)")[![SamuelMunoz](https://avatars.githubusercontent.com/u/694248?v=4)](https://github.com/SamuelMunoz "SamuelMunoz (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/partechgss-laravel-feature-toggle/health.svg)

```
[![Health](https://phpackages.com/badges/partechgss-laravel-feature-toggle/health.svg)](https://phpackages.com/packages/partechgss-laravel-feature-toggle)
```

###  Alternatives

[symfony/polyfill-uuid

Symfony polyfill for uuid functions

688335.4M63](/packages/symfony-polyfill-uuid)[spatie/error-solutions

This is my package error-solutions

6853.2M11](/packages/spatie-error-solutions)[phpflo/phpflo

Flow-based programming for PHP

2173.3k4](/packages/phpflo-phpflo)[eftec/autoloadone

AutoloadOne is a program that generates an autoload class for PHP.

403.4k](/packages/eftec-autoloadone)[ys-tools/default-theme-configuration-bundle

OroCommerce Default Theme Configuration Bundle

124.2k](/packages/ys-tools-default-theme-configuration-bundle)

PHPackages © 2026

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