clearlyip / laravel-flipt
A Flipt client for Laravel
Requires
- php: ^8.4
- laravel/framework: ^12.32.5 || ^13.0
- laravel/pennant: ^1.22.0
- spatie/php-cloneable: ^1.0
Requires (Dev)
- blastcloud/guzzler: 2.3.0
- brianium/paratest: ^7.19.0
- carthage-software/mago: ^1.15
- guzzlehttp/guzzle: ^7.10.0
- guzzlehttp/psr7: ^2.9.0
- mockery/mockery: ^1.6.12
- orchestra/testbench: ^11.0.0
- pestphp/pest: ^4.4.0
- rector/rector: ^2.3.9
- symfony/cache: ^7.3.2 || ^8.0
- vimeo/psalm: ^6.16.0
- vlucas/phpdotenv: ^5.6.2
This package is auto-updated.
Last update: 2026-03-24 18:34:39 UTC
README
Laravel-flipt was created by, and is maintained by Andrew Nagy, the package is designed to allow Laravel to work with Flipt
Features
- Registers as a driver for Laravel Pennant
- Registers a Flipt client class to access the API directly
- Utilizes Laravel's cache system to store flags in cache for quick access with configurable TTL
- Supports boolean and variant flag evaluation
- Supports batch evaluation via the
clientevaluationAPI - Provides access to Flipt's Environments, Flags, Evaluate, OpenFeature, and Internal APIs
- Ships with Artisan commands to clear flag caches globally or per user
Installation & Usage
Requires PHP 8.4+
Require Laravel-flipt using Composer:
composer require clearlyip/laravel-flipt
Laravel Version Compatibility
| Laravel | Laravel Flipt |
|---|---|
| 12.x | 1.x |
| 12.x, 13.x | 2.x |
Usage
Configuration Files
Publish the Laravel Flipt configuration file using the vendor:publish Artisan command. The flipt configuration file will be placed in your config directory (use --force to overwrite an existing config file):
php artisan vendor:publish --tag="flipt" [--force]
All options are fully documented in the published configuration file.
Key environment variables:
| Variable | Default | Description |
|---|---|---|
FLIPT_HOST |
null |
The Flipt API host URL |
FLIPT_NAMESPACE |
null |
The Flipt namespace |
FLIPT_ENVIRONMENT |
local |
The Flipt environment |
Pennant
Register the driver for Laravel Pennant in the pennant.php configuration file:
'default' => env('PENNANT_STORE', 'flipt'), 'stores' => [ 'array' => [ 'driver' => 'array', ], 'flipt' => [ 'driver' => 'flipt', ], ],
User Identity
Use the hasFeatures trait on your User model.
Configure what parameters to use for entityId and context in the flipt configuration file. Dot notation is supported for nested model attributes:
'identity' => [ 'identifier' => 'id', 'context' => [ 'email' => 'email', 'my-value' => 'dot.notation.is.supported', ], ],
Accessing the Flipt Client
The Flipt class can be resolved through Laravel's service container:
use Clearlyip\LaravelFlipt\Flipt; $flipt = App::make(Flipt::class);
The client exposes the following API modules as magic properties:
| Property | Class | Description |
|---|---|---|
$flipt->evaluate |
Flipt\Evaluate |
Boolean and variant flag evaluation |
$flipt->clientevaluation |
Flipt\ClientEvaluation |
Batch/client-side evaluation |
$flipt->openfeature |
Flipt\OpenFeature |
OpenFeature-compatible evaluation |
$flipt->environments |
Flipt\Environments |
Manage Flipt environments |
$flipt->flags |
Flipt\Flags |
List and retrieve flag definitions |
$flipt->internal |
Flipt\Internal |
Internal Flipt API access |
Disabling the Cache
To skip the cache for a single call chain, use withSkipCache():
$flipt->withSkipCache()->evaluate->boolean($request);
Artisan Commands
| Command | Description |
|---|---|
php artisan flipt:cache:clear |
Clear all cached Flipt flag responses |
php artisan flipt:cache:user:clear {userId} |
Clear cached flags for a specific user |
Caching
The package uses Laravel's cache system to cache Flipt API responses. Configure the cache behavior in config/flipt.php:
'cache' => [ 'store' => env('FLIPT_CACHE_STORE', 'default'), 'prefix' => env('FLIPT_CACHE_PREFIX', 'flipt'), 'ttl' => env('FLIPT_CACHE_TTL', 60), 'tags' => ['flipt'], ],
The cache store must support tagging (e.g., Redis, Memcached) for the cache-clearing commands to work correctly.
Contributing
Contributions are welcome. Please open an issue or pull request on GitHub.
License
Laravel-flipt is open-sourced software licensed under the MIT License.