bytexr / laravel-pennant-launchdarkly
Laravel Pennant LaunchDarkly Driver
Installs: 29 089
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- laravel/pennant: ^1.4
- launchdarkly/server-sdk: ^5.1
Requires (Dev)
- laravel/pint: ^1.11
README
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'), '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.