clearlyip/laravel-flipt

A Flipt client for Laravel

Maintainers

Package info

github.com/clearlyip/laravel-flipt

pkg:composer/clearlyip/laravel-flipt

Statistics

Installs: 846

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

2.0.0 2026-03-24 18:31 UTC

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

Total Downloads Latest Stable Version License

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 clientevaluation API
  • 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.