PHPackages                             flagdash/sdk - 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. flagdash/sdk

ActiveLibrary

flagdash/sdk
============

Official server-side FlagDash SDK for PHP

v0.1.0(today)01↑2900%MITPHPPHP ^8.1

Since Aug 25Pushed todayCompare

[ Source](https://github.com/flagdash/flagdash-php)[ Packagist](https://packagist.org/packages/flagdash/sdk)[ RSS](/packages/flagdash-sdk/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

FlagDash PHP SDK
================

[](#flagdash-php-sdk)

Feature flags, remote config, AI configs, translations and experiments for PHP 8.1+.

Dependency-free: the default transport uses PHP streams, so there is nothing to install beyond the package itself.

Installation
------------

[](#installation)

```
composer require flagdash/sdk
```

To install straight from GitHub, add `https://github.com/flagdash/flagdash-php`as a Composer VCS repository and require the immutable tag `v0.1.0`.

Quick start
-----------

[](#quick-start)

```
use FlagDash\Client;

$client = new Client($_ENV['FLAGDASH_SDK_KEY']);

if ($client->flag('checkout-v2', false, ['user_id' => 'alice'])) {
    // new checkout
}

$client->close();
```

API key tiers
-------------

[](#api-key-tiers)

The key decides which project and environment you read, and what you may reach. There is no `environment` parameter anywhere in this SDK — the key carries it.

KeyPrefixReachesClient`pk_`Flag values and configs. Safe in a browser or mobile app.Server`sk_`Everything the client key reaches, plus targeting rules, translations and experiments. Keep it on your server.Anything below marked **server key** returns nothing useful with a client key.

Configuration
-------------

[](#configuration)

```
$client = new Client(
    sdkKey: $_ENV['FLAGDASH_SDK_KEY'],
    baseUrl: 'https://flagdash.io',  // self-hosted? point it here
    timeout: 5.0,                    // seconds per request
    cacheTtl: 60.0,                  // seconds; 0 disables caching
    region: 'eu-west-1',             // omit to auto-detect
    transport: new StreamTransport(),
);
```

`region` is detected from `FLY_REGION`, `AWS_REGION` and friends when you leave it out, so region-scoped targeting rules work with no wiring. `transport` takes any `FlagDash\Transport`, which is where a PSR-18 client or a test double goes.

Feature flags
-------------

[](#feature-flags)

```
// A single flag, with a fallback used whenever FlagDash cannot be reached.
$enabled = $client->flag('checkout-v2', false, ['user_id' => 'alice']);

// Every flag for this context, in one request.
$flags = $client->allFlags(['user_id' => 'alice', 'country' => 'GB']);

// Why did it resolve that way? (server key)
$detail = $client->flagDetail('checkout-v2', false, ['user_id' => 'alice']);
// ['value' => true, 'reason' => 'rule_match', 'variation' => 'treatment', ...]

// Flag metadata without evaluating anything (server key).
$all = $client->listFlags();
```

**Pass a `user_id`** (or `key`) in the context whenever you want a stable answer. Percentage rollouts and A/B variations hash that identifier, so an anonymous context re-rolls on every call by design.

Context is a plain array. Any attribute you send can be targeted on:

```
$client->flag('beta-banner', false, [
    'user_id' => 'alice',
    'country' => 'GB',
    'plan'    => 'premium',
    'email'   => 'alice@example.com',
]);
```

Remote config
-------------

[](#remote-config)

```
$limit = $client->config('rate_limit', 100);
$all   = $client->listConfigs();
```

AI configs
----------

[](#ai-configs)

Prompts, agents, skills and rules, versioned per environment and editable without a deploy.

```
$prompt = $client->aiConfig('support-agent.md');
$files  = $client->listAiConfigs();
```

Translations (server key)
-------------------------

[](#translations-server-key)

```
$greeting = $client->translation('checkout.greeting', 'fr', 'Hello', [
    'name' => 'Alice',
]);
```

The key is `namespace.message`. `{placeholders}` are filled from the variables array, and the default is returned whenever the catalogue, the namespace or the message is missing — a translation lookup never throws.

Experiments (server key)
------------------------

[](#experiments-server-key)

```
$assignment = $client->experiment('checkout-redesign', ['user_id' => 'alice']);

if ($assignment !== null && $assignment['variant'] === 'treatment') {
    // ...
}

$client->trackExperimentMetric(
    experimentKey: 'checkout-redesign',
    eventName: 'purchase',
    userId: 'alice',
    value: 42.50,
    properties: ['currency' => 'GBP'],
);
```

`experiment()` returns `null` for a context with no identifier — an assignment that cannot be stable is worse than no assignment.

Metrics are buffered in memory (up to 1000) and sent by `flush()`, which `close()` calls for you:

```
$client->flush();  // send now
$client->close();  // flush and release the transport
```

In a long-running worker, call `flush()` periodically. In a request/response process, `close()` at the end of the request is enough.

Caching
-------

[](#caching)

Responses are cached in memory for `cacheTtl` seconds (60 by default), so a burst of `flag()` calls costs one request. `clearCache()` empties it.

```
$client->clearCache();
```

Failure behaviour
-----------------

[](#failure-behaviour)

Every read returns the default you passed rather than throwing, so an outage degrades to your fallback values instead of an exception in a request path. `FlagDash\FlagDashException` surfaces only for programming errors such as an empty SDK key.

Security
--------

[](#security)

Keep the server key on the server. A key granted only the scopes it needs limits the blast radius if it leaks, and a client key never returns targeting rules — the browser cannot see who else you are targeting.

License
-------

[](#license)

MIT

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity32

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

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22822385?v=4)[Vitor Águila](/maintainers/vitoraguila)[@vitoraguila](https://github.com/vitoraguila)

### Embed Badge

![Health badge](/badges/flagdash-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/flagdash-sdk/health.svg)](https://phpackages.com/packages/flagdash-sdk)
```

PHPackages © 2026

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