PHP code example of countxvat / launchdarkly-bundle

1. Go to this page and download the library: Download countxvat/launchdarkly-bundle 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/ */

    

countxvat / launchdarkly-bundle example snippets


if ($this->get('countx_launchdarkly.client')->variation('my-flag')) {
    //new feature
}

if ($this->get('countx_launchdarkly.client')->variation('my-flag', true)) {
    //new feature
}

if (\countX\LaunchDarklyBundle\Client\StaticClient::variation('my-flag', true)) {
    //new feature
}

interface KeyProvider
{
    public function userKey();
}

interface UserFactory
{
    public function create($key);
}

use countX\LaunchDarklyBundle\User\UserFactory;use LaunchDarkly\LDUserBuilder;

class IPUserFactory implements UserFactory
{
    public function create($key)
    {
        $ip = $_SERVER['REMOTE_ADDR'];
        return (new LDUserBuilder($key))->ip($ip)->build();
    }
    
}

if ($this->get('countx_launchdarkly.user_client')->variation('my-flag', new LDClient('the-user-id'))) {
    //new feature
}

if (\countX\LaunchDarklyBundle\Client\ExplicitUser\StaticClient::variation('my-flag', new LDClient('the-user-id'))) {
    //new feature
}

// app/AppKernel.php

public function registerBundles()
{
    $bundles = [
        //...
        new new countX\LaunchDarklyBundle\countXLaunchDarklyBundle(),
    ];
}


countx_launchdarkly.user_client