| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This provider allows for using LaunchDarkly with the OpenFeature SDK for PHP.
This provider is designed primarily for use in multi-user systems such as web servers and applications. It follows the server-side LaunchDarkly model for multi-user contexts. It is not intended for use in desktop and embedded systems applications.
LaunchDarkly is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. Get started using LaunchDarkly today!
This version of the LaunchDarkly provider works with PHP 8.1 and above.
Example composer dependencies:
{
"require": {
"php": ">=8.1",
"launchdarkly/openfeature-server": "^1.0"
}
}use OpenFeature\OpenFeatureAPI;
use OpenFeature\implementation\flags\Attributes;
use OpenFeature\implementation\flags\EvaluationContext;
$provider = new LaunchDarkly\OpenFeature\Provider("my-sdk-key");
$api = OpenFeatureAPI::getInstance();
$api->setProvider($provider);
// Refer to OpenFeature documentation for getting a client and performing evaluations.Refer to the SDK reference guide for instructions on getting started with using the SDK.
For information on using the OpenFeature client please refer to the OpenFeature Documentation.
LaunchDarkly evaluates contexts, and it can either evaluate a single-context, or a multi-context. When using OpenFeature both single and multi-contexts must be encoded into a single EvaluationContext. This is accomplished by looking for an attribute named kind in the EvaluationContext.
There are 4 different scenarios related to the kind:
The kind attribute should be a string containing only contain ASCII letters, numbers, ., _ or -.
The OpenFeature specification allows for an optional targeting key, but LaunchDarkly requires a key for evaluation. A targeting key must be specified for each context being evaluated. It may be specified using either targetingKey, as it is in the OpenFeature specification, or key, which is the typical LaunchDarkly identifier for the targeting key. If a targetingKey and a key are specified, then the targetingKey will take precedence.
There are several other attributes which have special functionality within a single or multi-context.
$context = new EvaluationContext("the-key");$attributes = new Attributes(["kind" => "organization"]);
$context = new EvaluationContext("org-key", $attributes);$attributes = [
"kind" => "multi",
"organization" => [
"name" => "the-org-name",
"targetingKey", "my-org-key",
"myCustomAttribute", "myAttributeValue"
],
"user" => [
"key" => "my-user-key",
"anonymous", true
]
];
$context = new EvaluationContext(null, new Attributes($attributes));$attributes = [
"kind" => "organization",
"myCustomAttribute" => "myAttributeValue",
"privateAttributes" => ["myCustomAttribute"]
];
$context = new EvaluationContext("org-key", new Attributes($attributes));$attributes = [
"kind" => "organization",
"organization" => [
"name" => "the-org-name",
"targetingKey" => "my-org-key",
// This will ONLY apply to the "organization" attributes.
"privateAttributes" => ["myCustomAttribute"],
// This attribute will be private.
"myCustomAttribute" => "myAttributeValue",
],
"user" => [
"key" => "my-user-key",
"anonymous" = > true,
// This attribute will not be private.
"myCustomAttribute" => "myAttributeValue",
]
];
$context = new EvaluationContext(null, new Attributes($attributes));Check out our documentation for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the complete reference guide for this SDK.
The authoritative description of all properties and methods is in the php documentation.
We encourage pull requests and other contributions from the community. Check out our contributing guidelines for instructions on how to contribute to this SDK.
| Back | FazBrowse Home | New Git URL |