PHPackages                             kameleoon/openfeature-php - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. kameleoon/openfeature-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kameleoon/openfeature-php
=========================

Kameleoon OpenFeature PHP

0.0.1(1y ago)13AGPL-3.0-or-laterPHP

Since Oct 14Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

Kameleoon OpenFeature provider for 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
----------------------

[](#supported-php-versions)

This version of the SDK is built for the following targets:

- PHP 8.0 and above.

Get started
-----------

[](#get-started)

This section explains how to install, configure, and customize the Kameleoon OpenFeature provider.

### Install dependencies

[](#install-dependencies)

First, install the required dependencies in your application.

add in composer.json

```
{
  "require": {
    "kameleoon/openfeature-php": ">=0.0.1"
  }
}
```

```
composer install
```

### Usage

[](#usage)

The following example shows how to use the Kameleoon provider with the OpenFeature SDK.

```
use OpenFeature\implementation\flags\Attributes;
use OpenFeature\implementation\flags\EvaluationContext;
use OpenFeature\OpenFeatureAPI;
use Kameleoon\KameleoonProvider;
use Kameleoon\KameleoonClientConfig;

$clientConfig = new KameleoonClientConfig(
    "clientId",
    "clientSecret",
);

$provider = new KameleoonProvider('siteCode', $clientConfig);
$api = OpenFeatureAPI::getInstance();
$api->setProvider($provider);
$client = $api->getClient();

$dataDictionary = [
    'variableKey' => 'stringKey'
];
$evalContext = new EvaluationContext("visitorCode", new Attributes($dataDictionary));

$evaluationDetails = $client->getStringDetails("featureKey", 5, $evalContext);

$numberOfRecommendedProducts = $evaluationDetails->getValue();
print_r("Number of recommended products: " . $numberOfRecommendedProducts);
```

#### Customize the Kameleoon provider

[](#customize-the-kameleoon-provider)

You can customize the Kameleoon provider by changing the `KameleoonClientConfig` object that you passed to the constructor above. For example:

```
$clientConfig = new KameleoonClientConfig(
    clientId: "clientId",
    clientSecret: "clientSecret",
    kameleoonWorkDir: "/tmp/kameleoon/php-client/", // kameleoonWorkDir: optional / ("/tmp/kameleoon/php-client/" by default)
    refreshIntervalMinute: 60, // refreshIntervalMinute: in minutes, optional (60 minutes by default)
    defaultTimeoutMillisecond: 10_000, // defaultTimeoutMillisecond: in milliseconds, optional (10_000 ms by default)
    debugMode: false, // debugMode: optional (false by default)
    cookieOptions: $cookieOptions, // cookieOptions: optional
    environment: "development" // environment: optional ("production" by default)
);

$provider = new KameleoonProvider('siteCode', $clientConfig);
```

Note

For additional configuration options, see the [Kameleoon documentation](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/php-sdk/#example-code).

EvaluationContext and Kameleoon Data
------------------------------------

[](#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 the `EvaluationContext` to the visitor code (user ID). If the value is not provided, then the `defaultValue` parameter will be returned.

```
$values = [
  'variableKey' => 'stringKey'
];

$evalContext = new EvaluationContext("userId", new Attributes($values));
```

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:

ParameterDescription`DataType::CUSTOM_DATA`The parameter is used to set [`CustomData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/php-sdk/#customdata) for a visitor.`DataType::CONVERSION`The parameter is used to track a [`Conversion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/php-sdk/#conversion) for a visitor.### DataType::CUSTOM\_DATA

[](#datatypecustom_data)

Use `DataType::CUSTOM_DATA` to set [`CustomData`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/php-sdk/#customdata) for a visitor. The `DataType::CUSTOM_DATA` field has the following parameters:

ParameterTypeDescription`CustomDataType::INDEX`intIndex or ID of the custom data to store. This field is mandatory.`CustomDataType::VALUES`string or arrayValue of the custom data to store. This field is mandatory.#### Example

[](#example)

```
$customeDataDictionary = [
    DataType::CUSTOM_DATA => [
        CustomDataType::INDEX => 1,
        CustomDataType::VALUES => '10'
    ]
];

$evalContext = new EvaluationContext("userId", new Attributes($customeDataDictionary));
```

### DataType::CONVERSION

[](#datatypeconversion)

Use `DataType::CONVERSION` to track a [`Conversion`](https://developers.kameleoon.com/feature-management-and-experimentation/web-sdks/php-sdk/#conversion) for a visitor. The `DataType::CONVERSION` field has the following parameters:

ParameterTypeDescription`ConversionType::GOAL_ID`intIdentifier of the goal. This field is mandatory.`ConversionType::REVENUE`floatRevenue associated with the conversion. This field is optional.#### Example

[](#example-1)

```
$conversionDictionary = [
    DataType::CONVERSION => [
        ConversionType::GOAL_ID => 1,
        ConversionType::REVENUE => 200
    ]
];

$evalContext = new EvaluationContext("userId", new Attributes($conversionDictionary));
```

### Use multiple Kameleoon Data types

[](#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.

```
$dataDictionary = [
    DataType::CONVERSION => [
        ConversionType::GOAL_ID => 1,
        ConversionType::REVENUE => 200
    ],
    DataType::CUSTOM_DATA => [
        [
            CustomDataType::INDEX => 1,
            CustomDataType::VALUES => ['10', '30']
        ],
        [
            CustomDataType::INDEX => 2,
            CustomDataType::VALUES => '20'
        ]
    ]
];

$evalContext = new EvaluationContext("userId", $dataDictionary);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

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

Unknown

Total

1

Last Release

581d ago

### Community

Maintainers

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

---

Tags

sdkkameleoonopenfeeature

### Embed Badge

![Health badge](/badges/kameleoon-openfeature-php/health.svg)

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

###  Alternatives

[aws/aws-crt-php

AWS Common Runtime for PHP

420300.1M4](/packages/aws-aws-crt-php)[zumba/amplitude-php

PHP SDK for Amplitude

409.5M5](/packages/zumba-amplitude-php)[ennnnny/tbk

简约优雅的淘宝客SDK

29016.1k1](/packages/ennnnny-tbk)[anilcancakir/laravel-ai-sdk-skills

A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.

151.1k](/packages/anilcancakir-laravel-ai-sdk-skills)

PHPackages © 2026

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