Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This topic documents how to get started with the LaunchDarkly OpenFeature provider for the PHP SDK.LaunchDarkly’s OpenFeature providers are open source. In addition to this reference guide, we provide source, API reference documentation, and a sample application:
| Resource | Location |
|---|---|
| OpenFeature Provider API documentation | Provider API docs |
| GitHub repository | openfeature-php-server |
| Sample application | Sample OpenFeature PHP provider application |
| Published module | Packagist |
Get started
The LaunchDarkly OpenFeature provider for the PHP SDK is intended for use in multi-user systems such as web servers and application. It is not intended for use in desktop and embedded systems applications. Follow these instructions to start using the LaunchDarkly OpenFeature provider for the PHP SDK in your application.Version compatibility
The LaunchDarkly OpenFeature provider for the PHP SDK is compatible with the OpenFeature PHP SDK v2.x and above. The provider is compatible with PHP 8.1+.Install the provider
First, add the LaunchDarkly OpenFeature package:Initialize the provider
After you install and import the provider, create a single, shared instance ofProvider. Specify your SDK key here to authorize your application to connect to a particular environment within LaunchDarkly.
Here’s how:
The LaunchDarkly PHP provider uses an SDK key. Keys are specific to each project and environment. They are available from Project settings, on the Environments list. To learn more about key types, read Keys.
Construct a context
A context is a generalized way of referring to the people, services, machines, or other resources that encounter feature flags in your product. The OpenFeature specification calls these evaluation contexts. In the LaunchDarkly provider, contexts:- always have a particular context kind. If you do not specify a kind, the provider treats the context as having a “user” kind. To specify a different kind, including a multi-context, you must include a
kindattribute. - must have a targeting key. This is optional in the OpenFeature specification, but LaunchDarkly requires a key for evaluation. You can specify this using
targetingKey, as in the OpenFeature specification, orkey, which is the typical LaunchDarkly identifier for the targeting key.