beqqaa / laravel-feature-flags
Simple, extendable and automated feature flag system for Laravel
v0.0.2
2025-04-07 21:51 UTC
Requires
- php: ^8.0
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
README
A simple, extendable, and automated feature flag system for Laravel.
Supports caching, automatic API routing, and publishable configuration & migrations.
๐ Features
- โ Feature toggling using database
- โ Facade and service-based access
- โ Publishable migration & config
- โ Automatic route registration for REST API
- โ Ready for integration with external admin UI
๐ฆ Installation
composer require beqqaa/laravel-feature-flags
If you're using Laravel 8โ11, you're good to go.
๐ง Publish Config & Migration
php artisan vendor:publish --tag=feature-flags-config php artisan vendor:publish --tag=feature-flags-migrations php artisan migrate
โ Usage
Enable a feature
Feature::enable('new_checkout');
Disable a feature
Feature::disable('new_checkout');
Check if a feature is enabled
if (Feature::isEnabled('new_checkout')) { // Show new checkout }
๐ง API Endpoints
Method | Endpoint | Description |
---|---|---|
GET | /api/feature-flags |
Get all feature flags |
POST | /api/feature-flags |
Create new flag |
PUT | /api/feature-flags/{key} |
Update flag status |
DELETE | /api/feature-flags/{key} |
Delete flag |
Endpoint prefix and middleware can be configured.
โ๏ธ Configuration (config/feature-flags.php
)
return [ 'cache_ttl' => 60, // In minutes. Set to 0 to disable caching. 'route_prefix' => 'api/feature-flags', 'middleware' => ['api'], // Add 'auth:sanctum' or others as needed ];
๐งฉ React Admin UI (Optional)
This package is backend-only.
To manage flags visually, check out the upcoming frontend dashboard (React + Vite) at:
Coming soon: beqqaa/feature-flags-dashboard
๐งช Testing & Development
Coming soon: unit tests and mock support.
๐ค Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss.
๐ License
MIT ยฉ beqqaa