Looking to hire Laravel developers? Try LaraJobs

laravel-pennant-launchdarkly maintained by bytexr

Description
Laravel Pennant LaunchDarkly Driver
Last update
2025/07/10 18:41 (dev-main)
License
Links
Downloads
68 510

Comments
comments powered by Disqus

Laravel Pennant LaunchDarkly

Introduction

Laravel Pennant LaunchDarkly simplifies the integration of Laravel Pennant with LaunchDarkly, offering a seamless experience.

Installation

composer require bytexr/laravel-pennant-launchdarkly

To make the necessary updates, navigate to config/services.php and add the following code:

return [
    ...

    'launch-darkly' => [
        'key'     => env('LAUNCH_DARKLY_KEY'),
        'dynamodb'     => [
            'table' => env('LAUNCH_DARKLY_DYNAMODB_TABLE')
        ],
        'options' => [],
    ]

];

If already haven't, publish Laravel Pennant config and add store to the config file in config/pennant.php:


    'stores' => [
        ...

        'launch-darkly' => [
            'driver' => 'launch-darkly'
        ]

    ]

Ensure that all required environment variables are set in your .env file, and don't forget to set the PENNANT_STORE value to launch-darkly.

Extends User model and all other scopes used in Pennant with HasLaunchDarklyContext interface and implement methods:

class User extends Authenticatable implements HasLaunchDarklyContext
{
    ...
    
    public function getLaunchDarklyContext(): LDContext|LDUser
    {
        return (new LDUserBuilder($this->getKey()))
            ->email($this->email)
            ->build();
    }
    
    // OR if you would like to use context instead

    public function getLaunchDarklyContext(): LDContext|LDUser
    {
        return LDContext::builder('user')
                        ->set('email', $this->email)
                        ->build();
    }
}

License

Laravel Pennant LaunchDarkly is open-sourced software licensed under the MIT license.