PHPackages                             jkbennemann/laravel-features - 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. jkbennemann/laravel-features

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

jkbennemann/laravel-features
============================

The package provides a convenient way to introduce new functionalities into your application by simply switching them on or off or granting access only to specific groups of users.

0.2.0(4y ago)07[3 PRs](https://github.com/jkbennemann/laravel-features/pulls)MITPHPPHP ^8.0|^8.1

Since Feb 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/jkbennemann/laravel-features)[ Packagist](https://packagist.org/packages/jkbennemann/laravel-features)[ Docs](https://github.com/jkbennemann/laravel-features)[ GitHub Sponsors](https://github.com/jkbennemann)[ RSS](/packages/jkbennemann-laravel-features/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Features
================

[](#laravel-features)

This packages provides a simple to use possibility to introduce functionality (`features`) to specific users or groups of users (`parties`).

This concept is also known as FeatureFlags or FeatureToggles.

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

[](#installation)

You can install the package via composer:

```
composer require jkbennemann/laravel-features
```

After you have installed the package run the following command start the installation routine

```
#Interactive installation
php artisan feature:install

#Command if you are using uuids for your model
php artisan feature:install --uuid

#Command if you are using unsigned big integer (id)
php artisan feature:install --id
```

### Last steps

[](#last-steps)

Migrate database files

```
php artisan migrate
```

Adding `HasFeatures` trait to your `User` model

```
//..
use Jkbennemann\Features\Models\Traits\HasFeatures;

class User extends Model
{
    use HasFeatures;
    //..
}
```

*After these steps you're good to go.*

Common Use-Cases
----------------

[](#common-use-cases)

### 1. A/B testing

[](#1-ab-testing)

1. Add you `features` which should be tested
2. Create two `parties` and add users to them
3. Assign features to the parties or single users

### 2. A group of Beta-Testers

[](#2-a-group-of-beta-testers)

1. Add you `features` which should be beta-tested
2. Create a new `party` fpr you beta-testers
3. Assign the users to that party

### 3. Preparation for an upcoming feature

[](#3-preparation-for-an-upcoming-feature)

1. Add a new `feature` which should be `INACTIVE` for now
2. Complete development and optionally create a special group for users e.g.
    developers that should still be able to access that new feature
3. Extend that feature to beta-testers or remove feature-switch

### 4. Functionality for specific users like administrators

[](#4-functionality-for-specific-users-like-administrators)

1. Create a new `party` for administrators
2. Assign all `features` which should be explicitly available for them to that party
3. Add all relevant users to that party.

Usage
-----

[](#usage)

```
use \Jkbennemann\Features\Models\Enums\FeatureStatus;
use \Jkbennemann\Features\Models\Feature;

$feature = Features::create([
    'name' => 'Functionality A',
    'description' => 'This is a new feature', //optional
    'status' => FeatureStatus::ACTIVE //optional, defaults to INACTIVE
]);

$party = Party::create([
    'name' => 'Beta Testers',
    'description' => 'This is a new party', //optional
    'status' => FeatureStatus::ACTIVE //optional, defaults to INACTIVE
]);

$feature->activate();       //activates a feature
$feature->deactivate();     //deactivates a feature

$party->addFeature($feature);       //assigns a feature to a party
$party->removeFeature($feature);    //removes a feature from a party

$active = $user->hasFeature($feature);        //user has the feature which is active
$active = $user->hasFeature('feature-slug');  //you may provide the slug of a feature
$active = $user->hasFeature('feature-slug', false); //provide false ignore the check for active features
$active = $user->hasFeatureThroughParty('feature-slug');    //checks if a feature is granted through a party

$features = $user->allFeatures();   //returns all features
$features = $user->allFeatures(false);   //returns all features without checking the status

$user->giveFeature('feature-slug');     //add specific feature to a user
$user->removeFeature('feature-slug');   //remove specific feature

$user->joinParty('party-slug');     //add a user to a party
$user->addToParty('party-slug');    //add a user to a party
$user->leaveParty('party-slug');    //remove a user from a party

$user->belongsToParty('party-slug');    //checks if the user belongs to the party
$user->inParty('party-slug');           //checks if the user belongs to the party
```

Commands
--------

[](#commands)

```
# Create a new feature/party
php artisan feature:add {name} {description?} {--status}
php artisan party:add {name} {description?} {--status}

# List features/parties
php artisan feature:list
php artisan party:list

# Activate a feature/party
php artisan feature:activate {id|slug}
php artisan party:activate {id|slug}

# Deactivate a feature/party
php artisan feature:deactivate {id|slug}
php artisan party:deactivate {id|slug}
```

Gates
-----

[](#gates)

```
# Check feature
$user->can('feature-slug');   //allows to check using laravel gates
$user->can('feature-slug', true);    //validates if feature is ACTIVE
$user->can('feature-slug', false);    //ignores status of feature
```

Ideas
-----

[](#ideas)

- Blade directives for `@feature`, `@party`
- Command to update feature status
- Gate support
- Support for UUIDs for `User` model
- Support `can()` method to use accept a `Feature` model
- Middleware to secure requests for features/parties
- Feature expiration to tackle [carying costs](https://martinfowler.com/articles/feature-toggles.html#WorkingWithFeature-flaggedSystems)
- Management for Parties/Features using Livewire

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Feel free to make suggestions of features or contribute by creating a Pull Request.
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Jakob Bennemann](https://github.com/jkbennemann)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 78.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 ~2 days

Total

2

Last Release

1549d ago

PHP version history (2 changes)0.1.0PHP ^8.0

0.2.0PHP ^8.0|^8.1

### Community

Maintainers

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

---

Top Contributors

[![jkbennemann](https://avatars.githubusercontent.com/u/25330395?v=4)](https://github.com/jkbennemann "jkbennemann (80 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (11 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")

---

Tags

laravelfeature-togglesfeature switchlaravel-featuresjkbennemann

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/jkbennemann-laravel-features/health.svg)

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

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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