> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP SDK - OpenFeature Provider

> Use the Westyx Nexus PHP SDK as an OpenFeature provider.

The `westyx/nexus-openfeature` package lets you use Westyx Nexus as an [OpenFeature](https://openfeature.dev) provider in PHP applications. It wraps an already-initialized `NexusClient` and delegates all evaluations to the in-memory cache - no additional network calls are made.

## Installation

<Warning>
  `westyx/nexus-openfeature` is not yet available in the Composer Package Registry. The GitLab Composer registry can only register the root package per repository; the OpenFeature provider lives in a sub-directory and cannot be published via the same tag-based mechanism. A dedicated Composer distribution is planned. Until then, install from source by copying the `openfeature/src/` directory from the [PHP SDK repository](https://gitlab.com/westyx/nexus/sdk/php) into your project.
</Warning>

Once the package is distributed, installation will be:

```sh theme={null}
composer require westyx/nexus-openfeature
```

**Requires:** PHP 8.3+, `open-feature/sdk` ^2.0, `westyx/nexus` >=0.8.0.

## Usage

```php theme={null}
use OpenFeature\OpenFeatureAPI;
use Westyx\NexusOpenFeature\NexusProvider;
use WestyxNexus\NexusClient;
use WestyxNexus\NexusConfig;

// Initialize the Nexus client (performs the initial sync).
$nexus = NexusClient::create(new NexusConfig(
    baseUrl: 'https://yourslug.westyx.dev',
    apiKey:  getenv('NEXUS_API_KEY'),
));

// Register the provider globally.
$api = OpenFeatureAPI::getInstance();
$api->setProvider(new NexusProvider($nexus));

// Evaluate flags and configs via the OpenFeature client.
$client = $api->getClient();

$darkMode = $client->getBooleanValue('dark-mode', false);
$apiUrl   = $client->getStringValue('api.url', 'https://default.example.com');
$timeout  = $client->getIntegerValue('timeout.seconds', 30);
$rate     = $client->getFloatValue('rate.limit', 100.0);
$dbConf   = $client->getObjectValue('db.config', []);
```

## Evaluation behavior

| Type    | Nexus method            | Not found                          | Wrong type                      |
| ------- | ----------------------- | ---------------------------------- | ------------------------------- |
| Boolean | `getFlag(key, default)` | Returns default, reason `STATIC`   | n/a                             |
| String  | `getConfig(key)`        | `FLAG_NOT_FOUND`, reason `DEFAULT` | `TYPE_MISMATCH`, reason `ERROR` |
| Integer | `getConfig(key)`        | `FLAG_NOT_FOUND`, reason `DEFAULT` | `TYPE_MISMATCH`, reason `ERROR` |
| Float   | `getConfig(key)`        | `FLAG_NOT_FOUND`, reason `DEFAULT` | `TYPE_MISMATCH`, reason `ERROR` |
| Object  | `getConfig(key)`        | `FLAG_NOT_FOUND`, reason `DEFAULT` | `TYPE_MISMATCH`, reason `ERROR` |

`EvaluationContext` is ignored - Nexus has no per-user targeting. All successful resolutions return reason `STATIC`.
