PHPackages                             mohamedhekal/laravel-featurebox - 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. mohamedhekal/laravel-featurebox

ActiveLibrary

mohamedhekal/laravel-featurebox
===============================

A simple, flexible feature toggle system for Laravel — control the visibility of features across environments, users, and conditions.

v1.0.1(9mo ago)10MITPHPPHP ^8.1CI passing

Since Jul 26Pushed 9mo agoCompare

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

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Laravel FeatureBox
==================

[](#laravel-featurebox)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8076ca3431111bdf5ece9af3f945460e991309b0cd77244f19c97ef14fc3b055/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6f68616d656468656b616c2f6c61726176656c2d66656174757265626f782e737667)](https://packagist.org/packages/mohamedhekal/laravel-featurebox)[![Tests](https://github.com/mohamedhekal/laravel-featurebox/workflows/Tests/badge.svg)](https://github.com/mohamedhekal/laravel-featurebox/actions?query=workflow%3ATests)[![Code Style](https://github.com/mohamedhekal/laravel-featurebox/workflows/Code%20Style/badge.svg)](https://github.com/mohamedhekal/laravel-featurebox/actions?query=workflow%3A%22Code+Style%22)[![Total Downloads](https://camo.githubusercontent.com/d4629f15ae68ce9534bfdf73f00b4ef8589330a73e53c37a8b5663be3e890b50/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f68616d656468656b616c2f6c61726176656c2d66656174757265626f782e737667)](https://packagist.org/packages/mohamedhekal/laravel-featurebox)[![License](https://camo.githubusercontent.com/e01004e2a4289b25771f959d7800494a350f51e7f7cb94e99500e9387c5c4461/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6f68616d656468656b616c2f6c61726176656c2d66656174757265626f782e737667)](https://github.com/mohamedhekal/laravel-featurebox/blob/main/LICENSE)

> A simple, flexible feature toggle system for Laravel — control the visibility of features across environments, users, and conditions.

---

📋 Table of Contents
-------------------

[](#-table-of-contents)

- [Introduction](#-introduction)
- [Features](#-features)
- [Requirements](#-requirements)
- [Quick Start](#-quick-start)
- [Installation](#-installation)
- [Usage](#%EF%B8%8F-usage)
- [API Reference](#-api-reference)
- [Feature Conditions](#-feature-conditions)
- [Artisan Commands](#-artisan-commands)
- [Configuration](#-configuration)
- [Database Schema](#-database-schema)
- [Security](#-security)
- [Testing](#-testing)
- [Roadmap](#-roadmap)
- [Support](#-support)
- [Examples](#-examples)

---

🚀 Introduction
--------------

[](#-introduction)

**Laravel FeatureBox** is a lightweight Laravel package that helps you manage feature flags in your application.

Whether you're rolling out features gradually, testing beta features for specific users, or disabling features in production — FeatureBox gives you full control.

Inspired by tools like LaunchDarkly, but made for Laravel.

---

✨ Features
----------

[](#-features)

- 🚀 **Simple &amp; Lightweight** - Easy to install and use
- 🔧 **Flexible Conditions** - Support for environments, user roles, dates, and custom conditions
- ⚡ **High Performance** - Built-in caching support
- 🛠️ **Artisan Commands** - Manage features from the command line
- 🔒 **Secure** - No external API calls, all logic is local
- 📊 **Database Storage** - Features stored in your database
- 🧪 **Testable** - Comprehensive test suite included
- 🌍 **Multi-language** - Documentation in English and Arabic

---

📋 Requirements
--------------

[](#-requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10.0
- MySQL/PostgreSQL/SQLite

🚀 Quick Start
-------------

[](#-quick-start)

```
# Install the package
composer require mohamedhekal/laravel-featurebox

# Publish configuration and migrations
php artisan vendor:publish --tag=featurebox-config
php artisan vendor:publish --tag=featurebox-migrations

# Run migrations
php artisan migrate

# Enable a feature
php artisan featurebox:enable new_checkout

# Use in your code
if (FeatureBox::isEnabled('new_checkout')) {
    // New checkout flow
}
```

📦 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require mohamedhekal/laravel-featurebox
```

Then publish the config and migration files:

```
php artisan vendor:publish --tag=featurebox-config
php artisan vendor:publish --tag=featurebox-migrations
php artisan migrate
```

---

⚙️ Usage
--------

[](#️-usage)

Enable or disable features from the database or using Artisan commands.

### Basic Usage

[](#basic-usage)

```
use FeatureBox\Facades\FeatureBox;

if (FeatureBox::isEnabled('new_checkout')) {
    // Show new checkout flow
} else {
    // Show classic checkout
}
```

### With Context

[](#with-context)

You can pass context to evaluate conditions:

```
FeatureBox::isEnabled('new_checkout', [
    'user_id' => auth()->id(),
    'role'    => auth()->user()->role,
]);
```

### In Blade Templates

[](#in-blade-templates)

```
@if(FeatureBox::isEnabled('dark_mode'))

@endif
```

### In Controllers

[](#in-controllers)

```
public function checkout()
{
    if (FeatureBox::isEnabled('new_checkout')) {
        return view('checkout.new');
    }

    return view('checkout.classic');
}
```

---

📚 API Reference
---------------

[](#-api-reference)

### Core Methods

[](#core-methods)

#### `FeatureBox::isEnabled(string $feature, array $context = []): bool`

[](#featureboxisenabledstring-feature-array-context---bool)

Check if a feature is enabled for the given context.

```
// Basic check
$enabled = FeatureBox::isEnabled('new_feature');

// With context
$enabled = FeatureBox::isEnabled('premium_feature', [
    'user_id' => 123,
    'plan' => 'premium'
]);
```

#### `FeatureBox::isDisabled(string $feature, array $context = []): bool`

[](#featureboxisdisabledstring-feature-array-context---bool)

Check if a feature is disabled (opposite of `isEnabled`).

```
if (FeatureBox::isDisabled('old_feature')) {
    // Show alternative
}
```

#### `FeatureBox::enable(string $feature, array $conditions = []): bool`

[](#featureboxenablestring-feature-array-conditions---bool)

Enable a feature with optional conditions.

```
// Enable without conditions
FeatureBox::enable('simple_feature');

// Enable with conditions
FeatureBox::enable('conditional_feature', [
    'environments' => ['production'],
    'user_roles' => ['admin']
]);
```

#### `FeatureBox::disable(string $feature): bool`

[](#featureboxdisablestring-feature-bool)

Disable a feature.

```
FeatureBox::disable('deprecated_feature');
```

#### `FeatureBox::get(string $feature): ?array`

[](#featureboxgetstring-feature-array)

Get detailed information about a feature.

```
$feature = FeatureBox::get('my_feature');
// Returns: [
//     'name' => 'my_feature',
//     'is_enabled' => true,
//     'conditions' => [...],
//     'created_at' => '2024-01-01 00:00:00',
//     'updated_at' => '2024-01-01 00:00:00'
// ]
```

#### `FeatureBox::all(): array`

[](#featureboxall-array)

Get all features with their status.

```
$features = FeatureBox::all();
// Returns array of all features
```

---

🧠 Feature Conditions
--------------------

[](#-feature-conditions)

Each feature can include optional conditions like:

- ✅ Environments (`local`, `staging`, `production`)
- 👤 User roles or specific user IDs
- 📅 Start/end dates
- 🔧 Custom JSON conditions

### Example Conditions

[](#example-conditions)

```
{
  "environments": ["staging", "production"],
  "user_roles": ["admin", "beta"],
  "user_ids": [1, 2, 3],
  "start_date": "2025-01-01",
  "end_date": "2025-12-31",
  "custom": {
    "plan": "premium",
    "region": "US"
  }
}
```

Conditions will be evaluated dynamically before enabling any feature.

---

🧪 Artisan Commands
------------------

[](#-artisan-commands)

### Enable a Feature

[](#enable-a-feature)

```
# Enable without conditions
php artisan featurebox:enable new_checkout

# Enable with conditions
php artisan featurebox:enable new_checkout --conditions='{"environments":["production"],"user_roles":["admin"]}'
```

### Disable a Feature

[](#disable-a-feature)

```
php artisan featurebox:disable new_checkout
```

### List All Features

[](#list-all-features)

```
php artisan featurebox:list
```

---

🔧 Configuration
---------------

[](#-configuration)

The package configuration is located at `config/featurebox.php`:

```
return [
    'cache' => [
        'enabled' => env('FEATUREBOX_CACHE_ENABLED', true),
        'ttl' => env('FEATUREBOX_CACHE_TTL', 300), // 5 minutes
    ],

    'default_conditions' => [
        // Default conditions for all features
    ],

    'table' => env('FEATUREBOX_TABLE', 'features'),
];
```

### Environment Variables

[](#environment-variables)

```
FEATUREBOX_CACHE_ENABLED=true
FEATUREBOX_CACHE_TTL=300
FEATUREBOX_TABLE=features
```

---

📊 Database Schema
-----------------

[](#-database-schema)

The package creates a `features` table with the following structure:

```
CREATE TABLE features (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(255) UNIQUE NOT NULL,
    is_enabled BOOLEAN DEFAULT FALSE,
    conditions JSON NULL,
    created_at TIMESTAMP NULL,
    updated_at TIMESTAMP NULL
);
```

---

🔐 Security
----------

[](#-security)

All logic is scoped locally; no external API calls or tracking. You can optionally cache the features for performance using Laravel's cache system.

---

🧪 Testing
---------

[](#-testing)

```
composer test
```

### Example Test

[](#example-test)

```
use FeatureBox\Facades\FeatureBox;

public function test_feature_can_be_enabled()
{
    FeatureBox::enable('test_feature');

    $this->assertTrue(FeatureBox::isEnabled('test_feature'));
}
```

---

✅ Roadmap
---------

[](#-roadmap)

- Feature toggle logic
- JSON-based conditions
- Artisan commands
- Caching support
- Web UI dashboard
- A/B testing support
- Redis driver
- Feature analytics

---

🆘 Support
---------

[](#-support)

- **Documentation**: [GitHub Wiki](https://github.com/mohamedhekal/laravel-featurebox/wiki)
- **Issues**: [GitHub Issues](https://github.com/mohamedhekal/laravel-featurebox/issues)
- **Discussions**: [GitHub Discussions](https://github.com/mohamedhekal/laravel-featurebox/discussions)
- **Email**:

🧑‍💻 Developed by [Mohamed Hekal](https://github.com/mohamedhekal)
-----------------------------------------------------------------

[](#‍-developed-by-mohamed-hekal)

Feel free to submit issues, ideas, or pull requests.

### 🤝 Contributing

[](#-contributing)

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

### 📄 License

[](#-license)

This package is open-sourced under the [MIT license](LICENSE).

---

📚 Examples
----------

[](#-examples)

### E-commerce Example

[](#e-commerce-example)

```
// Enable new checkout for premium users only
FeatureBox::enable('new_checkout', [
    'user_roles' => ['premium'],
    'environments' => ['production']
]);

// In your checkout controller
public function checkout()
{
    $user = auth()->user();

    if (FeatureBox::isEnabled('new_checkout', [
        'user_id' => $user->id,
        'role' => $user->role
    ])) {
        return $this->newCheckout();
    }

    return $this->classicCheckout();
}
```

### Beta Testing Example

[](#beta-testing-example)

```
// Enable beta features for specific users
FeatureBox::enable('beta_dashboard', [
    'user_ids' => [1, 5, 10, 15],
    'start_date' => '2025-01-01',
    'end_date' => '2025-03-31'
]);
```

### Environment-Specific Features

[](#environment-specific-features)

```
// Enable debug features only in local environment
FeatureBox::enable('debug_panel', [
    'environments' => ['local']
]);
```

### Gradual Rollout

[](#gradual-rollout)

```
// Roll out to 10% of users
FeatureBox::enable('gradual_rollout', [
    'custom' => [
        'rollout_percentage' => 10
    ]
]);

// In your code
$user = auth()->user();
$rolloutHash = crc32($user->id . 'gradual_rollout');
$inRollout = ($rolloutHash % 100) < 10;

if (FeatureBox::isEnabled('gradual_rollout', [
    'rollout_percentage' => $inRollout ? 10 : 0
])) {
    // New feature
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance56

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Every ~0 days

Total

2

Last Release

290d ago

### Community

Maintainers

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

---

Top Contributors

[![mohamedhekal](https://avatars.githubusercontent.com/u/21014387?v=4)](https://github.com/mohamedhekal "mohamedhekal (11 commits)")

---

Tags

laravellaravel-packagea b testingfeature-flagsfeature-togglesfeature managementfeature-controlbeta-features

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/mohamedhekal-laravel-featurebox/health.svg)

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

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[qodenl/laravel-posthog

Laravel implementation for Posthog

3372.7k](/packages/qodenl-laravel-posthog)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[takielias/tablar-crud-generator

Laravel Tablar Crud Generator based on https://github.com/takielias/tablar

315.6k](/packages/takielias-tablar-crud-generator)

PHPackages © 2026

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