PHPackages                             leettech/laravel-flagger - 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. [Admin Panels](/categories/admin)
4. /
5. leettech/laravel-flagger

ActiveLibrary[Admin Panels](/categories/admin)

leettech/laravel-flagger
========================

v2.1.0(8y ago)89.6k—0%[3 issues](https://github.com/leettech/laravel-flagger/issues)PHP

Since Aug 29Pushed 8y ago9 watchersCompare

[ Source](https://github.com/leettech/laravel-flagger)[ Packagist](https://packagist.org/packages/leettech/laravel-flagger)[ RSS](/packages/leettech-laravel-flagger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (9)Used By (0)

Laravel Flagger
===============

[](#laravel-flagger)

Flagger is a package that has been designed to help you on enabling feature flags in Laravel projects.

- [Version Compatibility](#version-compatibility)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [flag](#flag)
    - [flagMany](#flagmany)
    - [hasFeatureEnabled](#hasfeatureenabled)
    - [FlaggerMiddleware](#flaggermiddleware)
    - [Getting enabled features for a model](#getting-enabled-features-for-a-model)
- [Flagger command](#flagger-command)

Version Compatibility
---------------------

[](#version-compatibility)

LaravelFlagger5.3.x1.x.x5.4.x2.x.xInstallation
------------

[](#installation)

To install through composer, simply add the following in your `composer.json` file:

```
{
    "require": {
        "leettech/laravel-flagger": "~2.0"
    }
}
```

And then run `composer install`.

### Quick Installation

[](#quick-installation)

The above installation can also be simplified by using the following command:

```
composer require "leettech/laravel-flagger=~2.0"
```

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

[](#configuration)

After installing the Flagger package, register the FlaggerServiceProvider in your config/app.php configuration file:

```
'providers' => [
    // Other service providers...
    Leet\Providers\FlaggerServiceProvider::class,
],
```

Also, add the Flagger facade to the aliases array in your app configuration file:

```
'aliases' => [
    // Other aliases...
    'Flagger' => Leet\Facades\Flagger::class,
],
```

Then run the migration script to create `features` and `flaggables` tables:

```
php artisan migrate
```

Publish the package configuration:

```
php artisan vendor:publish --provider="Leet\Providers\FlaggerServiceProvider"
```

And, in your `config/flagger.php` configuration file, specify which model will have feature flags associated to it (by default it's set to `App\User::class`).

Usage
-----

[](#usage)

First of all, make sure you have inserted your features in the `features` table in the database. You can use the model `Leet\Models\Feature` for this:

```
\Leet\Models\Feature::create([
    'name' => 'notifications',
    'description' => 'Notifications feature'
]);
```

### flag

[](#flag)

Use `\Flagger::flag($flaggable, $feature)` to attach a feature to a model:

```
$user = \App\User::first();
\Flagger::flag($user, 'notifications');
```

You can also add `Leet\Models\FlaggerTrait` to the model in order to make flagger methods available from it:

```
class User extends Model
{
    use \Leet\Models\FlaggerTrait;
}
$user = \App\User::first();
$user->flag('notifications');
```

### flagMany

[](#flagmany)

Use `\Flagger::flagMany($flaggables, $feature)` to attach a feature to a collection of models:

```
$users = \App\User::all();
\Flagger::flagMany($users, 'notifications');
```

### hasFeatureEnabled

[](#hasfeatureenabled)

Anywhere in the application, you can check if a user has access to a feature:

```
if ($user->hasFeatureEnabled('notifications')) {
    doSomething();
}
```

### FlaggerMiddleware

[](#flaggermiddleware)

To use the FlaggerMiddleware, you have to declare it in the application kernel:

```
protected $routeMiddleware = [
    // Other middleware...
    'flagger' => \Leet\Middleware\FlaggerMiddleware::class,
];
```

And on any authenticated route:

```
Route::get('notifications', 'NotificationsController@index')->middleware('flagger:notifications');
```

or

```
Route::group(['middleware' => 'flagger:notifications'], function () {
    Route::get('notifications', 'NotificationsController@index');
    Route::post('notifications', 'NotificationsController@store')
});
```

### Getting enabled features for a model

[](#getting-enabled-features-for-a-model)

By adding `Leet\Models\FlaggerTrait` to your model, you are able to access its enabled features:

```
// returns the features a user have access to
$user->features;
```

Flagger command
---------------

[](#flagger-command)

The flagger command accepts an integer, array, or a path to a csv containing a list of integers and adds a flag to each of them:

```
php artisan flagger notifications 1
// OR
php artisan flagger notifications 1 2 3
// OR
php artisan flagger notifications users.csv
// OR
php artisan flagger notifications users.csv --chunk=100
```

Be sure to create the flag before attempting to add it to any entity.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 89.8% 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 ~33 days

Recently: every ~45 days

Total

8

Last Release

2951d ago

Major Versions

v1.1.0 → v2.0.02018-03-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb04e85167fdedf06f427a6437aa5e9ffd71b9ef768b7caed030b42d14d7912d?d=identicon)[josimar-lemos](/maintainers/josimar-lemos)

![](https://avatars.githubusercontent.com/u/2873464?v=4)[Abel Neto](/maintainers/netoabel)[@netoabel](https://github.com/netoabel)

---

Top Contributors

[![josimarlemos](https://avatars.githubusercontent.com/u/4071440?v=4)](https://github.com/josimarlemos "josimarlemos (44 commits)")[![netoabel](https://avatars.githubusercontent.com/u/2873464?v=4)](https://github.com/netoabel "netoabel (5 commits)")

---

Tags

feature-flagslaravelphp

### Embed Badge

![Health badge](/badges/leettech-laravel-flagger/health.svg)

```
[![Health](https://phpackages.com/badges/leettech-laravel-flagger/health.svg)](https://phpackages.com/packages/leettech-laravel-flagger)
```

###  Alternatives

[jeroennoten/laravel-adminlte

Easy AdminLTE integration with Laravel

4.0k4.8M43](/packages/jeroennoten-laravel-adminlte)[dmstr/yii2-adminlte-asset

AdminLTE backend theme asset bundle for Yii 2.0 Framework

1.1k1.8M67](/packages/dmstr-yii2-adminlte-asset)[dwij/laraadmin

LaraAdmin is a Open source Laravel Admin Panel / CMS which can be used as Admin Backend, Data Management Tool or CRM boilerplate for Laravel with features like CRUD Generation, Module Manager, Media, Menus, Backups and much more

1.6k68.7k](/packages/dwij-laraadmin)[filament/spatie-laravel-media-library-plugin

Filament support for `spatie/laravel-medialibrary`.

1764.8M125](/packages/filament-spatie-laravel-media-library-plugin)[bezhansalleh/filament-exceptions

A Simple &amp; Beautiful Pluggable Exception Viewer for FilamentPHP's Admin Panel

193195.9k13](/packages/bezhansalleh-filament-exceptions)[filament/infolists

Easily add beautiful read-only infolists to any Livewire component.

1220.8M36](/packages/filament-infolists)

PHPackages © 2026

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