PHPackages                             defstudio/enum-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. defstudio/enum-features

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

defstudio/enum-features
=======================

A simple trait to enable a feature system using Enums and Laravel Pennant

v2.0.5(2y ago)162.3k↓67.4%[1 PRs](https://github.com/defstudio/enum-features/pulls)MITPHPPHP ^8.3CI passing

Since Jul 3Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/defstudio/enum-features)[ Packagist](https://packagist.org/packages/defstudio/enum-features)[ Docs](https://github.com/defstudio/enum-features)[ Fund](https://paypal.me/bdmstore)[ GitHub Sponsors](https://github.com/defstudio)[ RSS](/packages/defstudio-enum-features/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (8)Dependencies (13)Versions (12)Used By (0)

Enum Features
=============

[](#enum-features)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e28edde4740ab76fbd435cfac6da56706bff6051a6666f80b57e46a97cbba495/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656673747564696f2f656e756d2d66656174757265732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/defstudio/enum-features)[![GitHub Tests Action Status](https://camo.githubusercontent.com/afbded62fccc9aeaf4d9ccd6cbca6b3fa43f271e2ef46c06d8c785ad968bcedb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64656673747564696f2f656e756d2d66656174757265732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/defstudio/enum-features/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4dbf8c4771d7d06ae8153a14a78c08024d03e371e1dcdd9bffbc1bb7d9a59eaf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64656673747564696f2f656e756d2d66656174757265732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/defstudio/enum-features/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/b21e15227a53fbcbb5f3f96ed4dc4ace2cfb8e0e1e89b6eca19f0a750527b193/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64656673747564696f2f656e756d2d66656174757265732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/defstudio/enum-features)[![License](https://camo.githubusercontent.com/da031f9eaa01d8f5eecd01614323e130a609d73f133e77235813c55089670474/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64656673747564696f2f74656c6567726170683f7374796c653d666c61742663616368655365636f6e64733d33363030)](https://packagist.org/packages/defstudio/enum-features)[![Twitter Follow](https://camo.githubusercontent.com/693066b709807898103e87dd7be499e1ad0e773de86f7dc3037a98dbb7159db4/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f466162696f49766f6e613f6c6162656c3d466f6c6c6f77267374796c653d736f6369616c)](https://twitter.com/FabioIvona?ref_src=twsrc%5Etfw)

A simple trait to enable a feature system using Enums:

```
if(AppFeature::welcome_email->active()){
    Mail::to($newUser)->send(new WelcomeEmail($newUser));
}
```

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

[](#installation)

You can install the package via composer:

```
composer require defstudio/enum-features
```

Usage
-----

[](#usage)

Features can be enabled on any enum by using the `DefinesFeatures` trait:

```
use DefStudio\EnumFeatures\EnumFeatures;

enum AppFeature
{
    use DefinesFeatures; // ← simply add this

    case multi_language;
    case impersonate;
    case welcome_email;

    /* Feature resolution */

    //with a single method:
    protected function resolve(Authenticatable $user = null) {
        match($this){
            case self::multi_language => true,
            case self::impersonate => $user->isAdmin(),
            default => false;
        }
    }

    //or with a dedicated method:

    protected function resolveImpersonate(Authenticatable $user = null){
        return $user->isSuperAdmin();
    }
}
```

and should be registered in your Provider

```
class AppServiceProvider extends ServiceProvider
{
    //..

    public function boot(): void {
        AppFeature::defineFeatures();
    }
}
```

then, in code, a feature could be checked to be enabled:

```
if(AppFeature::multi_language->active()){
    //.. multi language specific code
}
```

An extensive documentation is available at

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. [Follow Us](https://twitter.com/FabioIvona) on Twitter for more updates about this package.

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

[](#contributing)

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)

- [Fabio Ivona](https://github.com/defstudio)
- [def:studio team](https://github.com/defstudio)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

Support us
----------

[](#support-us)

We at [def:studio](https://github.com/defstudio) strongly believe that open source is the foundation of all our business and we try to contribute to it by helping other projects to grow along with developing and maintaining our packages. You can support our work by sponsoring us on [github](https://github.com/sponsors/defstudio)!

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance59

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 64.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 ~42 days

Recently: every ~2 days

Total

8

Last Release

844d ago

Major Versions

v1.1.0 → v2.0.02024-04-19

PHP version history (3 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

v2.0.1PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/db5e0ab5568062368a52c61d67381c1a35be5e5c816968dd3883bc7ba2d46b53?d=identicon)[fabio.ivona](/maintainers/fabio.ivona)

---

Top Contributors

[![fabio-ivona](https://avatars.githubusercontent.com/u/8792274?v=4)](https://github.com/fabio-ivona "fabio-ivona (57 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")

---

Tags

laravelpennantfeaturesdefstudioenumsenum-features

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/defstudio-enum-features/health.svg)

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

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[nativephp/mobile

NativePHP for Mobile

1.1k102.1k147](/packages/nativephp-mobile)[stephenjude/filament-feature-flags

Filament implementation of feature flags and segmentation with Laravel Pennant.

123204.9k1](/packages/stephenjude-filament-feature-flags)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[cjmellor/level-up

This package allows users to gain experience points (XP) and progress through levels by performing actions on your site. It can provide a simple way to track user progress and implement gamification elements into your application

673118.8k](/packages/cjmellor-level-up)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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