PHPackages                             silverstripe/featureflags - 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. silverstripe/featureflags

AbandonedArchivedSilverstripe-vendormodule

silverstripe/featureflags
=========================

An experimental module for allowing admin-controlled feature flags in a SilverStripe app

0.1.x-dev(8y ago)712.3k↓100%3[4 issues](https://github.com/sminnee/silverstripe-featureflags/issues)[1 PRs](https://github.com/sminnee/silverstripe-featureflags/pulls)BSD-3-ClausePHP

Since Oct 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sminnee/silverstripe-featureflags)[ Packagist](https://packagist.org/packages/silverstripe/featureflags)[ RSS](/packages/silverstripe-featureflags/feed)WikiDiscussions master Synced today

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

Feature Flags
=============

[](#feature-flags)

This experimental module is for allowing admin-controlled feature flags in a SilverStripe app.

Releases
--------

[](#releases)

- `silverstripe/featureflags:~0.1.0`: compatible with SilverStripe 3. `0.1` branch in git.
- `silverstripe/featureflags:~0.2.0`: compatible with SilverStripe 4. `master` branch in git.

Usage
-----

[](#usage)

If your application code, use `SilverStripe\FeatureFlags\FeatureFlag::isEnabled` to determine if a flag is set.

### Making code feature-dependent

[](#making-code-feature-dependent)

```
use SilverStripe\FeatureFlags\FeatureFlag;
// ...
if(FeatureFlag::isEnabled('FEATURE_NAME', [ "Member" => Member::currentUser() ])) {
    $controller->SomeSetting = "some value";
}
```

The first argument is a feature codename. These work similarly to permission codenames. The second argument is a map of context data, described below.

The module doesn't provide any controls for *how* your application will change if the flag is enabled; that is up to you.

### Context

[](#context)

Context helps answer the question "when should this feature be shown?" For example, you may have a feature that you wish to enable for certain members. In other cases, you may have a feature that you wish to enable for certain projects or pages.

In the first example, `Member` would be required context. In the second example, `Project` or `SiteTree` would be.

Each feature definition (described below) includes a list of the context it expects. Based on this, the admin UI for controlling feature flags will provid different tools for selecting features.

### Definining new features

[](#definining-new-features)

To define new features, add new items to the array `SilverStripe\FeatureFlags\FeatureFlag.feature` in your config:

```
SilverStripe\FeatureFlags\FeatureFlag:
  features:
    - code: FEATURE_NAME
      title: My feature
      context:
        Member: Member
```

Each feature have the following options:

- **code:** This is the codename passed as the first argument to FeatureFlag::isEnabled(). By convention, we recommend UPPER\_SNAKE\_CASE for these.
- **title:** This is a title shown in the feature flag admin
- **context:** This is a map of the required context values. The keys are the context keys, and the values are the class or interface that the value passed must derive from. Scalar context is not allowed. Any context values specified here that are not passed to `FeatureFlag::isEnabled()` will result in an error.

### Feature admin

[](#feature-admin)

Your CMS UI will have a new section, `/admin/featureflags`. This is a simple modeladmin that lists each available feature and gives you some form controls for choosing which context values will result in an enabled feature.

[![screenshot](docs/images/feature-flag-admin.png)](docs/images/feature-flag-admin.png)

### Context field providers

[](#context-field-providers)

For each data type in the context, you will need to have a form control for editing it. These are provided by "context field providers".By default, we provide a simple context field provider for `SilverStripe\Security\Member`. This is defined in the class `SilverStripe\FeatureFlags\Context\MemberFieldProvider`.

If you are making feature flags dependent on your own data objects, you will probably want to add your own field provders. There are two steps necessary to do this:

- Define a class that implements `SilverStripe\FeatureFlags\Context\FieldProvider`.
- Attach that class to the FeatureFlagAdmin by adding an entry to the `context_field_providers` config setting.

The config setting looks like this:

```
SilverStripe\FeatureFlags\FeatureFlagAdmin:
  context_field_providers:
    SilverStripe\Security\Member: SilverStripe\FeatureFlags\Context\Member

```

- The key should be the context class that you wish to use the field provider with
- The value should be the class name of the field provider

###  Health Score

27

—

LowBetter than 52% of packages

Maintenance9

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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

3035d ago

### Community

Maintainers

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

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

### Embed Badge

![Health badge](/badges/silverstripe-featureflags/health.svg)

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

###  Alternatives

[silverstripe/multi-domain

Allows multiple domains to access one CMS instance, mapping them to different sections of the hierarchy

141.6k](/packages/silverstripe-multi-domain)

PHPackages © 2026

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