Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

This package aims to provide a fully-featured, yet simple feature flag configuration through environment variables for Laravel 8+

License

NotificationsYou must be signed in to change notification settings

rescaled/simple-feature

Repository files navigation

Latest Version on PackagistGitHub Tests Action StatusGitHub Code Style Action StatusTotal Downloads

Simple Feature allows you to define feature flags via environment variables and check for their state withinyour Laravel application. It also provides pre-defined middleware you can utilize for this use case.

Installation

You can install the package via composer:

composer require rescaled/simple-feature

Usage

Define feature flags

Feature flags are defined in your environment file. They must be defined in snake case as well as being prefixed withFEATURE_.

FEATURE_FIRST_TEST=trueFEATURE_SECOND_TEST=trueFEATURE_THIRD_TEST=falseFEATURE_FOURTH_TEST=false

Direct usage

You can directly access the package's methods as following.

SimpleFeature::enabled('firstTest')// trueSimpleFeature::disabled('firstTest')// falseSimpleFeature::allEnabled(['firstTest','secondTest'])// trueSimpleFeature::allDisabled(['thirdTest','fourthTest'])// trueSimpleFeature::allEnabled(['firstTest','thirdTest'])// falseSimpleFeature::allDisabled(['firstTest','thirdTest'])// false

Middleware

The package comes with two middlewares that allow to check whether a given set of features is enabled or disabled.

// FEATURE_REGISTRATION=true// FEATURE_ON_PREMISE=trueRoute::get('/register', [RegistrationController::class,'create'])->middleware('feature.enabled:registration');Route::get('/billing', [BillingController,'show'])->middleware('feature.disabled:onPremise');

If the feature hasn't the desired state the middleware will abort the request with a 404.

Blade

Furthermore, you can use conditional Blade directives to render content based on the state of a given feature flag.

@feature('registration')    <ahref="/register">Register</a>@endfeature
@unlessfeature('onPremise')...@endunlessfeature

Testing

composertest

Changelog

Please seeCHANGELOG for more information on what has changed recently.

Contributing

Please seeCONTRIBUTING for details.

Security Vulnerabilities

If you discover any security-related issues, please emailsecurity@rescaled.de instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please seeLicense File for more information.

About

This package aims to provide a fully-featured, yet simple feature flag configuration through environment variables for Laravel 8+

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp