oneduo/laravel-pennant-launchdarkly

A LaunchDarkly driver for Laravel Pennant
1,681 8
Install
composer require oneduo/laravel-pennant-launchdarkly
Latest Version:v0.1.2
PHP:^8.1
Laravel:10 · 11
License:MIT
Last Updated:Apr 20, 2026
Links: GitHub  ·  Packagist
Maintainer: mikaelpopowicz

LaunchDarkly driver for Laravel Pennant

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel Pennant driver for LaunchDarkly.

Installation

You can install the package via composer:

composer require oneduo/laravel-pennant-launchdarkly

Usage

You may use the driver in your existing Laravel Pennant configuration file, by setting your store's driver to LaunchDarklyDriver::class.

You should provide your SDK key in your store's configuration.

You may add any LaucnhDarkly cleint specific configuration options to the store's configuration.

A typical configuration might look like this:

// config/pennant.php

<?php

use Oneduo\LaravelPennantLaunchdarkly\LaunchDarklyDriver;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Pennant Store
    |--------------------------------------------------------------------------
    |
    | Here you will specify the default store that Pennant should use when
    | storing and resolving feature flag values. Pennant ships with the
    | ability to store flag values in an in-memory array or database.
    |
    | Supported: "array", "database"
    |
    */

    'default' => env('PENNANT_STORE', 'laucnhdarkly'),

    /*
    |--------------------------------------------------------------------------
    | Pennant Stores
    |--------------------------------------------------------------------------
    |
    | Here you may configure each of the stores that should be available to
    | Pennant. These stores shall be used to store resolved feature flag
    | values - you may configure as many as your application requires.
    |
    */

    'stores' => [
        // ...
        
        'laucnhdarkly' => [
            'driver' => LaunchDarklyDriver::class,
            'sdk_key' => env('LAUNCHDARKLY_SDK_KEY'),
            'options' => [],
        ],
    ],
];

Then, in your scopeable Model, for instance your User model, you should implement the FeatureScopeable interface, and provide a toFeatureIdentifier method.

<?php

namespace App\Models;

use Illuminate\Foundation\Auth\User as Authenticable;
use Laravel\Pennant\Contracts\FeatureScopeable;
use LaunchDarkly\LDUser;
use LaunchDarkly\LDUserBuilder;

class User extends Authenticable implements FeatureScopeable
{
    // ...
    public function toFeatureIdentifier(string $driver): LDUser
    {
        return (new LDUserBuilder($this->getKey()))
        // you may add more attributes to your LDUser
        // ->email($this->email)
        // ->firstName($this->firstname)
        // ->lastName($this->lastname)
        //->custom([...])
        ->build();
    }
}

Related documentation

Troubleshooting

[E1] Scope must be an instance of LDUser

This is most likely due to either the scope you are using, or the fact that your currently authenticated user not having implemented FeatureScopeable correctly.

Please check the usage instructions.

[E2] Not implemented, Launchdarkly driver does not support this method

The LaunchDarkly driver for Laravel Pennant only supports read operations, and does not support write operations. If you need to write to LaunchDarkly, you should use the LaunchDarkly platform or the REST API.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

oneduo/laravel-recaptcha-enterprise

This is my package laravel-recaptcha-enterprise

106,296 62
oneduo/laravel-gitlab-webhook-client

A client to handle incoming Gitlab webhook requests

2,605 7
offload-project/laravel-waitlist

Manage multiple waitlists in Laravel - perfect for beta programs, product launch...

3,861 57
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966

Version History

Version Released PHP Laravel License
v0.1.2 ^8.1 ^10.0|^11.0 MIT
v0.1.1 ^8.1 ^10.0 MIT
v0.1.0 ^8.1 ^10.0 MIT