This product is not supported for your selected Datadog site. ().
Getting started
Use agentless delivery to receive flag configuration directly from Datadog. The SDK evaluates flags locally from cached configuration.
Install the SDK
Install the Datadog PHP extension version 1.28.0 or later. Follow the PHP library installation instructions. The extension provides the Feature Flags API; an Agent and APM tracing are optional.
Use the Datadog PHP API with PHP 7 or later. For PHP 8 applications, you can also use the OpenFeature adapter.
Configure flag delivery
Set these environment variables before PHP starts:
Set DD_ENV to your Feature Flags environment. Use a Datadog API key. If your organization uses a site other than datadoghq.com, set DD_SITE. For the site selected on this page, use .
PHP requires an explicit DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=agentless setting. Registering a provider or setting DD_FEATURE_FLAGS_ENABLED=true alone does not start configuration delivery. If DD_FEATURE_FLAGS_ENABLED=false is set, remove it or set it to true.
Evaluate a flag
Create a Boolean flag named my-flag. Enable its Server distribution channel and enable it in the target environment.
For PHP 7 or PHP 8, create the Datadog client and evaluate the flag:
Both APIs use the same extension and environment settings. The first evaluation waits up to 10 seconds for initial configuration. If configuration is unavailable, the SDK returns the supplied default value. Later evaluations use available updates without starting another initialization wait.
Set the evaluation context
Define an evaluation context that identifies the user or entity for flag targeting. The targeting key is used for consistent traffic distribution, such as percentage rollouts. Additional attributes enable targeting rules, such as “enable for users in the US” or “enable for premium tier users.”
Datadog API
For the Datadog PHP API, pass context as an array with targetingKey and attributes keys:
Evaluation context attributes must be flat primitive values: strings, numbers, and Booleans. Nested arrays, objects, and null values are ignored for targeting and exposure reporting.
Evaluate flags
After setting up the client, you can evaluate flags throughout your application. Each flag is identified by a unique string key and evaluated with a typed method that returns a value of the expected type. If the flag does not exist or cannot be evaluated, the SDK returns the provided default value.
Boolean flags
Use getBooleanValue for flags that represent on/off or true/false conditions:
For numeric flags, use getIntegerValue or getFloatValue. These methods are appropriate when a feature depends on a numeric parameter such as a limit, percentage, or multiplier:
When you need more than just the flag value, use the get<Type>Details methods. These return both the evaluated value and metadata explaining the evaluation:
To receive flags through the Datadog Agent, configure the Agent with an API key and enable Remote Configuration. Set these application environment variables:
The application API stays the same. Configure service identification as needed for your application.
Migrate from Agent delivery
Set DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=agentless and provide DD_API_KEY in the PHP process environment. Keep DD_ENV matched to your flag environment. If your organization uses a site other than datadoghq.com, set DD_SITE. Then remove DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED and restart PHP workers.
Replacing only DD_EXPERIMENTAL_FLAGGING_PROVIDER_ENABLED=true with DD_FEATURE_FLAGS_ENABLED=true stops configuration delivery. PHP also requires an explicit source. To retain Agent delivery, set DD_FEATURE_FLAGS_CONFIGURATION_SOURCE=remote_config.
The SDK polls for flag updates every 30 seconds. The request timeout is 5 seconds. Configure these values with DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_POLL_INTERVAL_SECONDS and DD_FEATURE_FLAGS_CONFIGURATION_SOURCE_AGENTLESS_REQUEST_TIMEOUT_SECONDS.
Set DD_EXPERIMENTAL_FLAGGING_PROVIDER_INITIALIZATION_TIMEOUT_MS to change the first-evaluation timeout. Its default is 10000 milliseconds. Credentials, endpoint, and environment settings resolve at process startup. Restart PHP workers after changing them.
Agentless delivery requires the PHP library’s subprocess sidecar. The default auto sidecar mode uses a subprocess when available. Thread mode, including automatic fallback to thread mode, does not support agentless delivery.
You can test against a dedicated Datadog test environment with the real Datadog provider, or replace feature flag evaluation with a test double in unit tests.
The OpenFeature PHP SDK 2.1 does not include a built-in in-memory provider. For unit tests, wrap feature flag evaluation behind an application interface and inject a fake implementation:
The optional feature_flag.evaluations metric uses a separate OpenTelemetry (OTLP) export path. Set DD_METRICS_OTEL_ENABLED=true and configure an OTLP receiver to use this metric. These settings are not required to receive flags or send experiment exposures and evaluation-count events.
Agentless delivery sends experiment exposures and evaluation-count events through a local event proxy when available. Otherwise, the SDK sends these events directly to Datadog using DD_API_KEY and DD_SITE.
Exposures appear only for flags associated with an experiment. Standard feature flags without an experiment association do not generate exposure events. If exposures are missing:
Verify the flag is associated with an experiment in the Datadog UI.
For agentless delivery, verify the PHP process has a valid DD_API_KEY and the correct DD_SITE.
Verify the sidecar can reach a local event proxy or the Datadog event intake. With Agent delivery, check the Agent’s API key.
Use flat primitive attributes in the evaluation context. Nested arrays, objects, and null values are ignored for exposure reporting.
Further reading
Additional helpful documentation, links, and articles: