magmasoftwareengineering/rollout-openfeature-provider

OpenFeature Provider for magmasoftwareengineering/rollout — bridges the rollout engine to the OpenFeature evaluation API

Maintainers

Package info

bitbucket.org/magmasoftwareengineering/rollout-openfeature-provider

pkg:composer/magmasoftwareengineering/rollout-openfeature-provider

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

0.1.1 2026-05-20 12:08 UTC

This package is auto-updated.

Last update: 2026-05-20 12:09:04 UTC


README

OpenFeature Provider for magmasoftwareengineering/rollout. Bridges the rollout engine's runtime semantics — percentage rollouts, user targeting, named groups, request-parameter gating — to the OpenFeature evaluation API, so applications can speak the standard OpenFeature\Client surface while continuing to use rollout's storage and admin model underneath.

Installation

Requires PHP 8.3+.

composer require magmasoftwareengineering/rollout-openfeature-provider

While the package is not yet on Packagist, add the VCS repositories alongside your other dependencies in composer.json:

"repositories": [
    { "type": "vcs", "url": "git@bitbucket.org:magmasoftwareengineering/rollout.git" },
    { "type": "vcs", "url": "git@bitbucket.org:magmasoftwareengineering/rollout-openfeature-provider.git" }
]

Both repos are public on Bitbucket. SSH is preferred over HTTPS because Bitbucket aggressively rate-limits anonymous HTTPS clones (HTTP 429) — particularly for CI runners hammering the same source IP. Anyone with a Bitbucket account and a registered SSH key can clone these repos.

Quick start

use MagmaSoftwareEngineering\Rollout\OpenFeature\RolloutProvider;
use MagmaSoftwareEngineering\Rollout\Rollout;
use MagmaSoftwareEngineering\Rollout\Storage\ArrayStorage;
use OpenFeature\OpenFeatureAPI;

$rollout = new Rollout(new ArrayStorage());
$rollout->activate('chat');

$api = OpenFeatureAPI::getInstance();
$api->setProvider(new RolloutProvider($rollout));

$client = $api->getClient('my-app');

$client->getBooleanValue('chat', false);  // true

Resolver behaviour

Boolean — direct delegation

resolveBooleanValue($flagKey, $default, $context) calls Rollout::isActive($flagKey, $user, $params) and returns:

Engine resultOpenFeature valuereason
truetrueTARGETING_MATCH
falsethe supplied defaultDEFAULT
throwsthe supplied defaultERROR

Typed — the data['value'] convention

Rollout 3.0 has no native variant concept, but Feature::getData() exposes a free-form payload that admin tooling (the wrapper's console command, the Slim controllers, your own code) can write to. This provider treats a 'value' key inside that payload as the typed flag value.

$rollout->activate('rate-limit');
$rollout->setFeatureData('rate-limit', ['value' => 250]);

$client->getIntegerValue('rate-limit', 100);  // 250

For each non-boolean resolver:

Engine stateResolver returnsreason
Feature active AND data['value'] present AND right typedata['value']TARGETING_MATCH
Feature active AND data['value'] absentthe supplied defaultDEFAULT
Feature active AND data['value'] wrong typethe supplied defaultDEFAULT
Feature inactivethe supplied defaultDEFAULT
Engine throwsthe supplied defaultERROR

The runtime type check is strict per PHP's is_* family:

  • resolveStringValue accepts only string.
  • resolveIntegerValue accepts only int (numeric strings or floats are rejected).
  • resolveFloatValue accepts only float (an integer literal 1 is rejected — write 1.0).
  • resolveObjectValue accepts any PHP array.

EvaluationContext mapping

OpenFeature conceptRollout mapping
EvaluationContext::getTargetingKey()Wrapped in a ContextUser (implements RolloutUserInterface). Empty / null → anonymous evaluation.
String attributePassed through as a rollout requestParameter.
Integer / float attributeString-cast ((string)) and passed through.
Boolean attributetrue'1', false'' (matches PHP's standard string cast).
Array attributeSilently skipped — rollout's request-param matching is string equality.
DateTime / null attributeSilently skipped.

Anonymous evaluation (no targeting key) still honours global activation and requestParameter rules.

Status

0.1.x — initial release. The data['value'] convention is the simplest mapping that works against rollout 3.0's existing storage shape; it may evolve as variant support is formalised in a future rollout major version (see the Pass 3 design notes in the Slim wrapper repo).

Compatibility

  • Engine: magmasoftwareengineering/rollout: ^3.0
  • OpenFeature SDK: open-feature/sdk: ^2.0
  • PHP: 8.3+

Contributing

See the engine's CONTRIBUTING.md. Same conventions apply: Codeception 5 (extend Codeception\Test\Unit), Psalm at level 4, British English in documentation.

Automated CI runs only on the maintainers' internal Gitea mirrors. Please run the suite locally (vendor/bin/codecept run Unit and vendor/bin/psalm) before opening a pull request.

Licence

MIT. See LICENSE.