magmasoftwareengineering / rollout-openfeature-provider
OpenFeature Provider for magmasoftwareengineering/rollout — bridges the rollout engine to the OpenFeature evaluation API
Package info
bitbucket.org/magmasoftwareengineering/rollout-openfeature-provider
pkg:composer/magmasoftwareengineering/rollout-openfeature-provider
Requires
- php: >=8.3 || >=8.5
- magmasoftwareengineering/rollout: ^3.0
- open-feature/sdk: ^2.0
Requires (Dev)
- codeception/codeception: ^5.3
- codeception/module-asserts: ^3.3
- roave/security-advisories: dev-latest
- vimeo/psalm: ^6.0
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 result | OpenFeature value | reason |
|---|---|---|
true | true | TARGETING_MATCH |
false | the supplied default | DEFAULT |
| throws | the supplied default | ERROR |
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 state | Resolver returns | reason |
|---|---|---|
Feature active AND data['value'] present AND right type | data['value'] | TARGETING_MATCH |
Feature active AND data['value'] absent | the supplied default | DEFAULT |
Feature active AND data['value'] wrong type | the supplied default | DEFAULT |
| Feature inactive | the supplied default | DEFAULT |
| Engine throws | the supplied default | ERROR |
The runtime type check is strict per PHP's is_* family:
resolveStringValueaccepts onlystring.resolveIntegerValueaccepts onlyint(numeric strings or floats are rejected).resolveFloatValueaccepts onlyfloat(an integer literal1is rejected — write1.0).resolveObjectValueaccepts any PHP array.
EvaluationContext mapping
| OpenFeature concept | Rollout mapping |
|---|---|
EvaluationContext::getTargetingKey() | Wrapped in a ContextUser (implements RolloutUserInterface). Empty / null → anonymous evaluation. |
| String attribute | Passed through as a rollout requestParameter. |
| Integer / float attribute | String-cast ((string)) and passed through. |
| Boolean attribute | true → '1', false → '' (matches PHP's standard string cast). |
| Array attribute | Silently skipped — rollout's request-param matching is string equality. |
DateTime / null attribute | Silently 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.