PHPackages                             launchdarkly/openfeature-server - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. launchdarkly/openfeature-server

ActiveLibrary

launchdarkly/openfeature-server
===============================

An OpenFeature provider for the LaunchDarkly PHP server SDK

1.0.0(1y ago)131.2k—1.4%1Apache-2.0PHPPHP &gt;=8.1CI passing

Since Apr 21Pushed 1mo ago26 watchersCompare

[ Source](https://github.com/launchdarkly/openfeature-php-server)[ Packagist](https://packagist.org/packages/launchdarkly/openfeature-server)[ RSS](/packages/launchdarkly-openfeature-server/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (8)Used By (0)

LaunchDarkly OpenFeature provider for the Server-Side SDK for PHP
=================================================================

[](#launchdarkly-openfeature-provider-for-the-server-side-sdk-for-php)

[![Run CI](https://github.com/launchdarkly/openfeature-php-server/actions/workflows/ci.yml/badge.svg)](https://github.com/launchdarkly/openfeature-php-server/actions/workflows/ci.yml)[![Packagist](https://camo.githubusercontent.com/c60585b56336bd692bc92b2ecc637e87b4ad07ea862bc16a75d7006f5837276f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61756e63686461726b6c792f6f70656e666561747572652d7365727665722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/launchdarkly/openfeature-server)[![Documentation](https://camo.githubusercontent.com/594b549773dcf2ae2c08cc82426986546623581e9e74bf421a89b823d9541bd2/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f6c6162656c3d4769744875622b5061676573266d6573736167653d4150492b7265666572656e636526636f6c6f723d303061646438)](https://launchdarkly.github.io/openfeature-php-server)

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 overview
=====================

[](#launchdarkly-overview)

[LaunchDarkly](https://www.launchdarkly.com) is a feature management platform that serves over 100 billion feature flags daily to help teams build better software, faster. [Get started](https://docs.launchdarkly.com/home/getting-started) using LaunchDarkly today!

[![Twitter Follow](https://camo.githubusercontent.com/e9df01ef2d0c328380d090b5edbe3b7b9e76ffb709b5b416511d6c7a5ba3a17f/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f666f6c6c6f772f6c61756e63686461726b6c792e7376673f7374796c653d736f6369616c266c6162656c3d466f6c6c6f77266d61784167653d32353932303030)](https://twitter.com/intent/follow?screen_name=launchdarkly)

Supported PHP versions
----------------------

[](#supported-php-versions)

This version of the LaunchDarkly provider works with PHP 8.1 and above.

Getting started
---------------

[](#getting-started)

### Requisites

[](#requisites)

Example composer dependencies:

```
{
    "require": {
        "php": ">=8.1",
        "launchdarkly/openfeature-server": "^1.0"
    }
}
```

### Usage

[](#usage)

```
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](https://docs.launchdarkly.com/sdk/server-side/php) for instructions on getting started with using the SDK.

For information on using the OpenFeature client please refer to the [OpenFeature Documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api/).

OpenFeature Specific Considerations
-----------------------------------

[](#openfeature-specific-considerations)

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`:

1. There is no `kind` attribute. In this case the provider will treat the context as a single context containing a "user" kind.
2. There is a `kind` attribute, and the value of that attribute is "multi". This will indicate to the provider that the context is a multi-context.
3. There is a `kind` attribute, and the value of that attribute is a string other than "multi". This will indicate to the provider a single context of the kind specified.
4. There is a `kind` attribute, and the attribute is not a string. In this case the value of the attribute will be discarded, and the context will be treated as a "user". An error message will be logged.

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.

- A key of `privateAttributes`. Must be an array of string values. [Equivalent to the 'private' builder method in the SDK.](https://launchdarkly.github.io/php-server-sdk/classes/LaunchDarkly-LDContextBuilder.html#method_private)
- A key of `anonymous`. Must be a boolean value. [Equivalent to the 'anonymous' builder method in the SDK.](https://launchdarkly.github.io/php-server-sdk/classes/LaunchDarkly-LDContextBuilder.html#method_anonymous)
- A key of `name`. Must be a string. [Equivalent to the 'name' builder method in the SDK.](https://launchdarkly.github.io/php-server-sdk/classes/LaunchDarkly-LDContextBuilder.html#method_name)

### Examples

[](#examples)

#### A single user context

[](#a-single-user-context)

```
$context = new EvaluationContext("the-key");
```

#### A single context of kind "organization"

[](#a-single-context-of-kind-organization)

```
$attributes = new Attributes(["kind" => "organization"]);
$context = new EvaluationContext("org-key", $attributes);
```

#### A multi-context containing a "user" and an "organization"

[](#a-multi-context-containing-a-user-and-an-organization)

```
$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));
```

#### Setting private attributes in a single context

[](#setting-private-attributes-in-a-single-context)

```
$attributes = [
    "kind" => "organization",
    "myCustomAttribute" => "myAttributeValue",
    "privateAttributes" => ["myCustomAttribute"]
];

$context = new EvaluationContext("org-key", new Attributes($attributes));
```

#### Setting private attributes in a multi-context

[](#setting-private-attributes-in-a-multi-context)

```
$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));
```

Learn more
----------

[](#learn-more)

Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](https://docs.launchdarkly.com/sdk/server-side/php).

The authoritative description of all properties and methods is in the [php documentation](https://launchdarkly.github.io/php-server-sdk/).

Contributing
------------

[](#contributing)

We encourage pull requests and other contributions from the community. Check out our [contributing guidelines](CONTRIBUTING.md) for instructions on how to contribute to this SDK.

About LaunchDarkly
------------------

[](#about-launchdarkly)

- LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
    - Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.
    - Gradually roll out a feature to an increasing percentage of users, and track the effect that the feature has on key metrics (for instance, how likely is a user to complete a purchase if they have feature A versus feature B?).
    - Turn off a feature that you realize is causing performance problems in production, without needing to re-deploy, or even restart the application with a changed configuration file.
    - Grant access to certain features based on user attributes, like payment plan (eg: users on the ‘gold’ plan get access to more features than users in the ‘silver’ plan). Disable parts of your application to facilitate maintenance, without taking everything offline.
- LaunchDarkly provides feature flag SDKs for a wide variety of languages and technologies. Check out [our documentation](https://docs.launchdarkly.com/sdk) for a complete list.
- Explore LaunchDarkly
    - [launchdarkly.com](https://www.launchdarkly.com/ "LaunchDarkly Main Website") for more information
    - [docs.launchdarkly.com](https://docs.launchdarkly.com/ "LaunchDarkly Documentation") for our documentation and SDK reference guides
    - [apidocs.launchdarkly.com](https://apidocs.launchdarkly.com/ "LaunchDarkly API Documentation") for our API documentation
    - [blog.launchdarkly.com](https://blog.launchdarkly.com/ "LaunchDarkly Blog Documentation") for the latest product updates

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance64

Regular maintenance activity

Popularity31

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~418 days

Total

2

Last Release

704d ago

Major Versions

0.1.0 → 1.0.02024-06-13

PHP version history (2 changes)0.1.0PHP &gt;=8.0

1.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/c7e78fd12fb89ed4e1494144fe649fb09b90f1aaa1bd34513b92190dddd73d6a?d=identicon)[launchdarkly](/maintainers/launchdarkly)

---

Top Contributors

[![keelerm84](https://avatars.githubusercontent.com/u/1922716?v=4)](https://github.com/keelerm84 "keelerm84 (21 commits)")[![kparkinson-ld](https://avatars.githubusercontent.com/u/93555788?v=4)](https://github.com/kparkinson-ld "kparkinson-ld (3 commits)")[![ld-repository-standards[bot]](https://avatars.githubusercontent.com/u/111005579?v=4)](https://github.com/ld-repository-standards[bot] "ld-repository-standards[bot] (3 commits)")[![devin-ai-integration[bot]](https://avatars.githubusercontent.com/in/811515?v=4)](https://github.com/devin-ai-integration[bot] "devin-ai-integration[bot] (1 commits)")[![pkaeding](https://avatars.githubusercontent.com/u/13951?v=4)](https://github.com/pkaeding "pkaeding (1 commits)")[![osm6495](https://avatars.githubusercontent.com/u/22415818?v=4)](https://github.com/osm6495 "osm6495 (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

feature-flagsfeature-toggleslaunchdarklylaunchdarkly-sdkmanaged-by-terraformopen-featurephpsdk

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/launchdarkly-openfeature-server/health.svg)

```
[![Health](https://phpackages.com/badges/launchdarkly-openfeature-server/health.svg)](https://phpackages.com/packages/launchdarkly-openfeature-server)
```

###  Alternatives

[netflie/whatsapp-cloud-api

The first PHP SDK to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform

640431.7k4](/packages/netflie-whatsapp-cloud-api)[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[flowwow/cloudpayments-php-client

cloudpayments api client

2188.2k](/packages/flowwow-cloudpayments-php-client)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
