PHPackages                             phpdominicana/flagship - 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. phpdominicana/flagship

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

phpdominicana/flagship
======================

Feature flags for Laravel in a super simple and fast way

v1.0.0(9mo ago)002MITPHPPHP ^8.1

Since Aug 9Pushed 9mo agoCompare

[ Source](https://github.com/PHP-Dominicana/Flagship)[ Packagist](https://packagist.org/packages/phpdominicana/flagship)[ RSS](/packages/phpdominicana-flagship/feed)WikiDiscussions main Synced 1mo ago

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

Flagship 🚩
==========

[](#flagship-)

A powerful and intelligent feature flag management package for Laravel applications. Take control of your feature rollouts with granular user targeting, A/B testing capabilities, and real-time feature toggling.

Why Flagship?
-------------

[](#why-flagship)

Feature flags (also known as feature toggles) allow you to deploy code to production while keeping new features hidden until you're ready to release them. This enables:

- **Safe deployments** - Deploy code without exposing features
- **Gradual rollouts** - Release features to a subset of users first
- **A/B testing** - Test different variations with different user groups
- **Quick rollbacks** - Disable problematic features instantly
- **Production testing** - Test features with real users in production

🚀 Quick Installation
--------------------

[](#-quick-installation)

```
composer require php-dominicana/flagship
php artisan vendor:publish --provider="Flagship\FlagshipServiceProvider"
php artisan migrate
```

---

✨ Creating feature flags
------------------------

[](#-creating-feature-flags)

### From Artisan

[](#from-artisan)

```
php artisan flagship:make new_feature --enabled
php artisan flagship:make beta_feature --description="Beta functionality"
```

### From code

[](#from-code)

```
use Flagship\Facades\Flagship;

Flagship::create('new_feature', true);
```

---

🔍 Simple checks
---------------

[](#-simple-checks)

```
if (Flagship::isEnabled('new_feature')) {
    // Code for the new feature
}

if (Flagship::isEnabled('beta_feature', auth()->user())) {
    // User-specific feature
}
```

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

[](#basic-usage)

### Checking Feature Flags

[](#checking-feature-flags)

```
use PhpDominicana\Flagship\Facades\Flagship;

// Simple feature check
if (Flagship::isEnabled('new-checkout')) {
    // Show new checkout flow
}

// User-specific feature check
if (Flagship::isEnabledForUser('beta-dashboard', $user)) {
    // Show beta dashboard to specific user
}

// Check with fallback
$showFeature = Flagship::isEnabled('experimental-ui', false);
```

---

🖌 Blade directives
------------------

[](#-blade-directives)

```
@flagship('new_feature')
    New feature enabled!
@endflagship
```

or

```
@feature('new-design')

@else

@endfeature

@featureForUser('premium-features', $user)

@endfeature
```

---

🔗 Middleware
------------

[](#-middleware)

Protect routes or route groups:

```
Route::middleware(['flagship:new_feature'])->group(function () {
    Route::get('/new-section', [Controller::class, 'newSection']);
});

Route::middleware(['feature:new-api'])->group(function () {
    Route::get('/api/v2/users', [UserController::class, 'index']);
});

// With user context
Route::middleware(['feature:beta-features,user'])->group(function () {
    Route::get('/beta/dashboard', [BetaController::class, 'dashboard']);
});
```

Feature Configuration
---------------------

[](#feature-configuration)

### Creating Features

[](#creating-features)

```
use PhpDominicana\Flagship\Models\Feature;

// Create a new feature
Feature::create([
    'name' => 'new-checkout',
    'description' => 'New streamlined checkout process',
    'is_active' => true,
    'rollout_percentage' => 25, // 25% of users
]);
```

### Feature Targeting

[](#feature-targeting)

Target specific user segments:

```
// Target by user attributes
$feature = Feature::create([
    'name' => 'premium-features',
    'targeting_rules' => [
        'user_type' => 'premium',
        'registration_date' => ['after' => '2024-01-01']
    ]
]);

// Target by custom logic
$feature = Feature::create([
    'name' => 'beta-ui',
    'targeting_strategy' => 'custom',
    'custom_evaluator' => BetaUserEvaluator::class
]);
```

Advanced Features
-----------------

[](#advanced-features)

### A/B Testing

[](#ab-testing)

Create feature variants for A/B testing:

```
$feature = Feature::create([
    'name' => 'checkout-flow',
    'variants' => [
        'control' => ['weight' => 50],
        'variant_a' => ['weight' => 25],
        'variant_b' => ['weight' => 25]
    ]
]);

// In your code
$variant = Flagship::getVariant('checkout-flow', $user);
switch ($variant) {
    case 'variant_a':
        return view('checkout.variant-a');
    case 'variant_b':
        return view('checkout.variant-b');
    default:
        return view('checkout.control');
}
```

### Scheduled Features

[](#scheduled-features)

Automatically enable/disable features based on schedule:

```
Feature::create([
    'name' => 'black-friday-sale',
    'scheduled_start' => '2024-11-29 00:00:00',
    'scheduled_end' => '2024-12-02 23:59:59',
]);
```

### Environment-based Features

[](#environment-based-features)

Different feature states per environment:

```
Feature::create([
    'name' => 'debug-toolbar',
    'environments' => [
        'local' => true,
        'staging' => true,
        'production' => false
    ]
]);
```

Analytics &amp; Monitoring
--------------------------

[](#analytics--monitoring)

### Feature Usage Tracking

[](#feature-usage-tracking)

```
// Track feature impressions
Flagship::track('new-checkout', $user, 'viewed');

// Track feature interactions
Flagship::track('new-checkout', $user, 'completed_purchase', [
    'amount' => 99.99,
    'items' => 3
]);
```

### Metrics Dashboard

[](#metrics-dashboard)

Access built-in analytics:

```
// Get feature adoption rates
$stats = Flagship::getFeatureStats('new-checkout');
// Returns: ['impressions' => 1000, 'interactions' => 150, 'conversion_rate' => 15%]

// A/B test results
$results = Flagship::getABTestResults('checkout-flow');
```

Management Interface
--------------------

[](#management-interface)

### Artisan Commands

[](#artisan-commands)

```
# List all features
php artisan flagship:list

# Enable a feature
php artisan flagship:enable new-checkout

# Disable a feature
php artisan flagship:disable new-checkout

# Set rollout percentage
php artisan flagship:rollout new-checkout --percentage=50

# Cleanup inactive features
php artisan flagship:cleanup
```

### API Endpoints

[](#api-endpoints)

Built-in REST API for external management:

```
GET /api/flagship/features
POST /api/flagship/features
PUT /api/flagship/features/{feature}
DELETE /api/flagship/features/{feature}
```

You can configure additional middleware for these API endpoints in your config file (see [Flexible configuration](#-flexible-configuration)).

---

🛠 Artisan commands
------------------

[](#-artisan-commands)

- List all feature flags:

    ```
    php artisan flagship:list
    ```
- Toggle a feature on/off:

    ```
    php artisan flagship:toggle new_feature
    ```
- Create a new feature:

    ```
    php artisan flagship:make my_flag --enabled --description="My description"
    ```

---

⚙️ Flexible configuration
-------------------------

[](#️-flexible-configuration)

You can adjust settings in the published config file:

```
// config/flagship.php

return [
    'cache_enabled' => true,
    'cache_ttl' => 3600,
    'default_state' => false,

    // Configure additional middleware for API endpoints
    'api' => [
        'middleware' => ['auth:sanctum'], // Example: Add authentication middleware
    ],
];
```

Or via environment variables:

```
FLAGSHIP_CACHE_ENABLED=true
FLAGSHIP_CACHE_TTL=3600
FLAGSHIP_DEFAULT_STATE=false

```

---

⚡ Performance
-------------

[](#-performance)

- Configurable automatic caching to reduce database lookups.
- Optimized SQL queries with proper indexing for lightning-fast checks.

---

📚 License
---------

[](#-license)

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

Support
-------

[](#support)

- 📖 [Documentation](https://docs.flagship.dev)
- 🐛 [Issue Tracker](https://github.com/PHP-Dominicana/Flagship/issues)
- 💬 [Discussions](https://github.com/PHP-Dominicana/Flagship/discussions)
- 🔗 [PHP Dominicana Community](https://php.do)

---

Built with ❤️ by the PHP Dominicana community

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance57

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

282d ago

### Community

Maintainers

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

---

Top Contributors

[![ivanmercedes](https://avatars.githubusercontent.com/u/53806989?v=4)](https://github.com/ivanmercedes "ivanmercedes (12 commits)")[![masterfermin02](https://avatars.githubusercontent.com/u/4625540?v=4)](https://github.com/masterfermin02 "masterfermin02 (10 commits)")[![elminson](https://avatars.githubusercontent.com/u/2476286?v=4)](https://github.com/elminson "elminson (8 commits)")

---

Tags

laravelflagsfeatureflagship

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/phpdominicana-flagship/health.svg)

```
[![Health](https://phpackages.com/badges/phpdominicana-flagship/health.svg)](https://phpackages.com/packages/phpdominicana-flagship)
```

###  Alternatives

[barryvdh/laravel-ide-helper

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

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[laravel/pennant

A simple, lightweight library for managing feature flags.

57311.1M53](/packages/laravel-pennant)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[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)
