PHPackages                             amirhf1/feature-flags - 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. amirhf1/feature-flags

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

amirhf1/feature-flags
=====================

This package provides a simple and flexible feature flag system for Laravel applications. It allows developers to enable or disable features dynamically, roll out features to a percentage of users, or restrict features to specific users.

v1.0.0(1y ago)06MITPHPPHP ^7.4 || ^8.0

Since Mar 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Amirhf1/feature-flag)[ Packagist](https://packagist.org/packages/amirhf1/feature-flags)[ Docs](https://github.com/Amirhf1/feature-flags)[ RSS](/packages/amirhf1-feature-flags/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

Feature Flags for Laravel
=========================

[](#feature-flags-for-laravel)

This package provides a simple and flexible feature flag system for Laravel applications. It allows developers to dynamically enable or disable features, roll out features to a percentage of users, or restrict features to specific users.

Features
--------

[](#features)

- **Toggle Features**: Enable or disable features dynamically.
- **Percentage Rollout**: Roll out features to a percentage of users.
- **User-Based Rollout**: Enable features only for specific users.
- **Database-Backed Flags**: Store feature flags in the database.
- **Config-Based Flags**: Define feature flags directly in the Laravel config file.
- **Command-Line Interface (CLI)**: Enable, disable, or list feature flags from the terminal.

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

[](#installation)

To install the package, run the following command:

```
composer require amirhf1/feature-flags
```

Once installed, you need to register the service provider in your Laravel application. Add the following line to the `providers` array in `config/app.php`:

```
Amirhf1\FeatureFlags\Providers\FeatureFlagsServiceProvider::class,
```

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

[](#configuration)

The package comes with a default configuration file. To publish the config file to your application, run:

```
php artisan vendor:publish --provider="Amirhf1\FeatureFlags\Providers\FeatureFlagsServiceProvider" --tag="config"
```

This will create the `config/feature-flags.php` file, where you can define and manage your feature flags.

Example of a feature flag in `config/feature-flags.php`:

```
return [
    'flags' => [
        'new_feature' => [
            'enabled' => true,
            'percentage' => 50,  // Enable for 50% of users
            'users' => [1, 2, 3],  // Enable for specific user IDs
        ],
    ],
];
```

Database Migrations
-------------------

[](#database-migrations)

To store feature flags in the database, you need to run the migration command:

```
php artisan migrate
```

This will create the `feature_flags` table in your database.

To create the migration file, run:

```
php artisan vendor:publish --provider="Amirhf1\FeatureFlags\Providers\FeatureFlagsServiceProvider" --tag="migrations"
```

This will copy the migration file to your `database/migrations` folder.

Usage
-----

[](#usage)

### Checking if a Feature is Enabled

[](#checking-if-a-feature-is-enabled)

You can check if a feature is enabled using the `FeatureFlags` class or the helper function.

```
use Amirhf1\FeatureFlags\Facades\FeatureFlags;

if (FeatureFlags::isEnabled('new_feature')) {
    // The feature is enabled, perform the feature-specific logic
}
```

Or using the helper function:

```
if (feature_enabled('new_feature')) {
    // The feature is enabled, perform the feature-specific logic
}
```

### Enabling and Disabling Features

[](#enabling-and-disabling-features)

You can enable or disable features programmatically or via the command line.

#### Enable a Feature:

[](#enable-a-feature)

```
FeatureFlags::enable('new_feature');
```

#### Disable a Feature:

[](#disable-a-feature)

```
FeatureFlags::disable('new_feature');
```

### Command-Line Interface (CLI)

[](#command-line-interface-cli)

The package provides several Artisan commands to interact with feature flags.

- **List all feature flags:**

    ```
    php artisan feature:list
    ```
- **Enable a feature flag:**

    ```
    php artisan feature:enable {feature_name}
    ```
- **Disable a feature flag:**

    ```
    php artisan feature:disable {feature_name}
    ```

Tests
-----

[](#tests)

To run the tests, you need to set up PHPUnit. Then, you can run the tests using:

```
php artisan test
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance45

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

425d ago

### Community

Maintainers

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/amirhf1-feature-flags/health.svg)

```
[![Health](https://phpackages.com/badges/amirhf1-feature-flags/health.svg)](https://phpackages.com/packages/amirhf1-feature-flags)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M686](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M211](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M860](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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