PHPackages                             al\_imran/runtime-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. al\_imran/runtime-feature-toggle

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

al\_imran/runtime-feature-toggle
================================

A runtime feature engine for Laravel applications.

v1.0.0(2d ago)00MITPHPPHP ^8.2

Since Jun 7Pushed 2d agoCompare

[ Source](https://github.com/alimranedx/runtime-feature-toggle)[ Packagist](https://packagist.org/packages/al_imran/runtime-feature-toggle)[ RSS](/packages/al-imran-runtime-feature-toggle/feed)WikiDiscussions dev Synced 2d ago

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

Runtime Feature Toggle
======================

[](#runtime-feature-toggle)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3d032f896ddf4f6d5b0935573d1547e0fa1e12a97ce339d1bca863cabfe340cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c5f696d72616e2f72756e74696d652d666561747572652d746f67676c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/al_imran/runtime-feature-toggle)[![Total Downloads](https://camo.githubusercontent.com/fffc21ed1fb1941640af5f5e6fcad444f8d78deb42f8939eac1bfd2779f72c4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c5f696d72616e2f72756e74696d652d666561747572652d746f67676c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/al_imran/runtime-feature-toggle)[![License](https://camo.githubusercontent.com/de463dba62ca68afd010aa8bee3bfcb33c8138741c26c9b7b7e3b4548caf0f91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616c5f696d72616e2f72756e74696d652d666561747572652d746f67676c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/al_imran/runtime-feature-toggle)

**Runtime Feature Toggle** is a high-performance, decoupled feature flag engine for Laravel. It allows you to dynamically control application behavior and configuration at runtime without code deployments or configuration changes.

### Instant Control, Zero Deployment

[](#instant-control-zero-deployment)

Imagine you need to pause all outgoing emails or SMS notifications during a maintenance window. Normally, you'd have to update an `.env` key or change your code and redeploy to production.

With **Runtime Feature Toggle**, you can toggle these features instantly via the database. The best part? Our **intelligent caching system** ensures that these checks are lightning-fast, giving you the power of dynamic control with the performance of local configuration.

---

Why Use This Package?
---------------------

[](#why-use-this-package)

In modern software development, decoupling feature releases from code deployments is critical. This package solves several common problems:

- **Safe Releases**: Gradually roll out features to specific users or segments.
- **Kill Switches**: Instantly disable problematic features in production without a rollback.
- **Dynamic Configuration**: Update logic parameters (like discount rates or API limits) via a dashboard instead of `.env` files.
- **Zero-Dependency Core**: Unlike many other packages, it doesn't force a specific User model or Auth structure on you.

Key Features
------------

[](#key-features)

- 🚀 **High Performance**: Atomic caching ensures evaluation is lightning fast.
- 💎 **Sleek Management UI**: Built-in dashboard to manage flags and JSON payloads.
- 🎭 **Contextual Awareness**: Evaluate flags based on Users, IPs, Request data, or any custom entity.
- 📦 **Dynamic Payloads**: Return complex JSON configurations, not just simple booleans.
- 🛠 **Extensible**: Easily add custom condition logic (e.g., "User belongs to Beta Team").
- 🧪 **Test-Ready**: Robust mocking support for your PHPUnit suites.

---

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

[](#installation)

You can install the package via composer:

```
composer require al_imran/runtime-feature-toggle
```

Setup
-----

[](#setup)

Run the installation command to publish the configuration, migrations, and assets:

```
php artisan feature:install
```

This command will:

1. Publish the `config/feature.php` file.
2. Publish and run the database migrations.
3. Prepare the package for use.

Feature Management
------------------

[](#feature-management)

This package comes with a built-in dashboard to add, edit, and maintain your feature flags without touching the database manually.

### Accessing the Dashboard

[](#accessing-the-dashboard)

By default, the dashboard is available at: `YOUR_APP_URL/features-manager`

From here, you can:

- **Add New Features**: Define keys and initial JSON payloads.
- **Toggle States**: Instantly enable or disable features globally.
- **Manage Rules**: Add complex conditions (like User ID or Time Ranges) to control feature availability.
- **Edit Payloads**: Update dynamic configuration values on the fly.

Customizing &amp; Securing the Dashboard
----------------------------------------

[](#customizing--securing-the-dashboard)

By default, the management dashboard is accessible at `/features-manager`. While this is convenient for development, you should secure it in production environments.

### Option 1: Using Configuration (Easiest)

[](#option-1-using-configuration-easiest)

The simplest way to protect the dashboard is by updating the `config/feature.php` file. You can add any middleware (like `auth` or custom admin middleware) to the `routes` array:

```
// config/feature.php
'routes' => [
    'prefix' => 'admin/features', // Change the URL prefix if desired
    'middleware' => ['web', 'auth', 'can:manage-features'], // Add your protection here
],
```

### Option 2: Taking Full Ownership of Routes

[](#option-2-taking-full-ownership-of-routes)

If you need even more control (e.g., adding extra routes or changing the route structure), you can publish the routes file to your application:

```
php artisan vendor:publish --tag=feature-routes
```

This will create `routes/runtimeFeature.php` in your project. The package will automatically detect and use this file instead of its internal routes. You can then modify the group directly:

```
// routes/runtimeFeature.php
Route::middleware(['web', 'auth', 'your-custom-admin-middleware'])
    ->prefix('features-manager')
    ->name('features.')
    ->group(function () {
        // Your customized routes...
    });
```

Important

**Security Reminder**: The developer is responsible for ensuring that the dashboard routes are properly protected. By default, only the `web` middleware is applied, which provides no authentication or authorization.

---

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

[](#basic-usage)

### 1. Simple On/Off Checks (`enabled`)

[](#1-simple-onoff-checks-enabled)

Use this to check if a feature is active.

```
use Imran\RuntimeFeatureToggle\Facades\Feature;

// Via Facade
if (Feature::enabled('new_checkout_flow')) {
    // Show the new checkout
}

// Via Helper
if (feature('new_checkout_flow')->enabled()) {
    // Show the new checkout
}
```

### 2. Retrieving Dynamic Values (`value`)

[](#2-retrieving-dynamic-values-value)

Fetch dynamic configurations stored with your feature flag.

```
// Returns the JSON payload from the DB.
// If the feature is missing, it returns null.
// If the feature exists but its value is empty, it returns the default (50).
$limit = Feature::value('upload_limit', 50);

// Helper syntax
$config = feature('theme_colors')->value(['primary' => '#000']);
```

MethodReturnsDescription`enabled()``bool`Is the feature active?`value()``mixed`Returns the dynamic JSON payload or a default.---

Advanced Usage
--------------

[](#advanced-usage)

### Contextual Evaluation

[](#contextual-evaluation)

Pass a context (e.g., a User model) to evaluate rules specifically for that entity.

```
$user = auth()->user();

if (Feature::enabled('beta_access', $user)) {
    // This user specifically has access based on rules defined in the dashboard
}
```

### Custom Conditions

[](#custom-conditions)

Register your own logic for rule evaluation.

```
// In a ServiceProvider
Feature::extend('user_level', function ($context, $value) {
    return $context->level >= $value;
});
```

### Mocking for Tests

[](#mocking-for-tests)

Avoid database hits in your tests by faking feature states.

```
public function test_new_feature_is_displayed()
{
    Feature::fake([
        'new_feature' => true,
        'api_limit' => 1000
    ]);

    $this->get('/dashboard')->assertSee('New Feature');
}
```

---

Real-World Use Cases
--------------------

[](#real-world-use-cases)

1. **Feature Rollout**: Enable `new_sidebar` for 10% of users to monitor performance before a full launch.
2. **A/B Testing**: Store different configuration values (e.g., button colors) in the `value` field to test user engagement.
3. **Emergency Toggles**: If a 3rd-party service goes down, instantly disable the integration via the dashboard to keep the rest of the app running.

---

Comparison: Laravel Pennant
---------------------------

[](#comparison-laravel-pennant)

While [Laravel Pennant](https://laravel.com/docs/pennant) is an excellent tool for user-centric feature flags, **Runtime Feature Toggle** differs in its focus:

- **Management UI**: We provide a ready-to-use dashboard for non-technical stakeholders to manage flags.
- **Dynamic Payloads**: We treat JSON configurations as first-class citizens, making it easier to use flags for remote config.
- **Decoupled Context**: Our engine doesn't assume an Eloquent User model, making it easier to use in non-standard or multi-tenant applications.

---

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

---

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

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

---

**Packagist Description:**A high-performance, decoupled feature flag engine with a management UI and dynamic JSON configuration support for Laravel.

**Keywords:**laravel, feature-flags, remote-config, feature-toggle, runtime-configuration

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/beb5b27606319886c465426ef3048610f96801590b208c19f47afa0a1c5bc379?d=identicon)[alimran.edx](/maintainers/alimran.edx)

---

Top Contributors

[![alimranedx](https://avatars.githubusercontent.com/u/109755564?v=4)](https://github.com/alimranedx "alimranedx (19 commits)")

### Embed Badge

![Health badge](/badges/al-imran-runtime-feature-toggle/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[flarum/core

Delightfully simple forum software.

261.4M2.2k](/packages/flarum-core)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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