PHP code example of oneduo / laravel-pennant-launchdarkly

1. Go to this page and download the library: Download oneduo/laravel-pennant-launchdarkly library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oneduo / laravel-pennant-launchdarkly example snippets


// config/pennant.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 
 


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();
    }
}