Download the PHP package spotify/confidence-openfeature-provider without Composer
On this page you can find all versions of the php package spotify/confidence-openfeature-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spotify/confidence-openfeature-provider
More information about spotify/confidence-openfeature-provider
Files in spotify/confidence-openfeature-provider
Package confidence-openfeature-provider
Short Description Confidence OpenFeature provider for PHP
License Apache-2.0
Informations about the package confidence-openfeature-provider
Confidence OpenFeature PHP Provider
This repo contains the OpenFeature PHP flag provider for Confidence.
Refer to the Confidence documentation for more information. Before starting to use the provider, it can be helpful to read through the general OpenFeature docs and get familiar with the concepts.
This library supports the same platforms as the OpenFeature PHP SDK. Requires PHP >= 8.2.
Note: This provider uses the online resolver approach. Flag evaluations are resolved by making API calls to the Confidence backend for each evaluation request. This is different from the local resolver approach used in other Confidence providers (Java, JavaScript, Go) which use WebAssembly (WASM) for local flag evaluation.
Install
Usage
Below is an example for how to create an OpenFeature client using the Confidence flag provider, and then resolve a flag with a boolean attribute. The provider is configured with a client secret and a base URL, which will determine where it will send the resolving requests.
The flag will be applied immediately, meaning that Confidence will count the targeted user as having received the treatment.
You can retrieve attributes on the flag variant using property dot notation, meaning test-flag.boolean-key will retrieve the attribute boolean-key on the flag test-flag.
You can also use only the flag name test-flag and retrieve all values as an array with resolveObjectValue().
Custom Resolver URL
You can point the provider at a local or custom resolver by passing any base URL:
Evaluation Context
The evaluation context contains information about the user/session being evaluated for targeting and A/B testing.
Error Handling
Important: This provider uses the online resolver approach - each flag evaluation makes a network call to Confidence. Proper error handling is critical!
The provider maps errors to standard OpenFeature error codes:
FLAG_NOT_FOUND- The requested flag does not exist or is not activeTYPE_MISMATCH- The flag value type does not match the requested type, or the key path is invalidGENERAL- Network or API errors