Download the PHP package kameleoon/openfeature-php without Composer
On this page you can find all versions of the php package kameleoon/openfeature-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kameleoon/openfeature-php
More information about kameleoon/openfeature-php
Files in kameleoon/openfeature-php
Package openfeature-php
Short Description Kameleoon OpenFeature PHP
License AGPL-3.0-or-later
Informations about the package openfeature-php
Kameleoon OpenFeature provider for PHP
The Kameleoon OpenFeature provider for PHP allows you to connect your OpenFeature PHP implementation to Kameleoon without installing the PHP Kameleoon SDK.
[!WARNING] This is a beta version. Breaking changes may be introduced before general release.
Supported PHP versions
This version of the SDK is built for the following targets:
- PHP 8.0 and above.
Get started
This section explains how to install, configure, and customize the Kameleoon OpenFeature provider.
Install dependencies
First, install the required dependencies in your application.
add in composer.json
Usage
The following example shows how to use the Kameleoon provider with the OpenFeature SDK.
Customize the Kameleoon provider
You can customize the Kameleoon provider by changing the KameleoonClientConfig
object that you passed to the constructor above. For example:
[!NOTE] For additional configuration options, see the Kameleoon documentation.
EvaluationContext and Kameleoon Data
Kameleoon uses the concept of associating Data
to users, while the OpenFeature SDK uses the concept of an EvaluationContext
, which is a dictionary of string keys and values. The Kameleoon provider maps the EvaluationContext
to the Kameleoon Data
.
[!NOTE] To get the evaluation for a specific visitor, set the
targeting_key
value for theEvaluationContext
to the visitor code (user ID). If the value is not provided, then thedefaultValue
parameter will be returned.
The Kameleoon provider provides a few predefined parameters that you can use to target a visitor from a specific audience and track each conversion. These are:
Parameter | Description |
---|---|
DataType::CUSTOM_DATA |
The parameter is used to set CustomData for a visitor. |
DataType::CONVERSION |
The parameter is used to track a Conversion for a visitor. |
DataType::CUSTOM_DATA
Use DataType::CUSTOM_DATA
to set CustomData
for a visitor. The DataType::CUSTOM_DATA
field has the following parameters:
Parameter | Type | Description |
---|---|---|
CustomDataType::INDEX |
int | Index or ID of the custom data to store. This field is mandatory. |
CustomDataType::VALUES |
string or array | Value of the custom data to store. This field is mandatory. |
Example
DataType::CONVERSION
Use DataType::CONVERSION
to track a Conversion
for a visitor. The DataType::CONVERSION
field has the following parameters:
Parameter | Type | Description |
---|---|---|
ConversionType::GOAL_ID |
int | Identifier of the goal. This field is mandatory. |
ConversionType::REVENUE |
float | Revenue associated with the conversion. This field is optional. |
Example
Use multiple Kameleoon Data types
You can provide many different kinds of Kameleoon data within a single EvaluationContext
instance.
For example, the following code provides one DataType::CONVERSION
instance and two DataType::CUSTOM_DATA
instances.