Feature Flags for Laravel

Feature Flags for Laravel

The Feature Flags package for Laravel by Peter Fox helps you handle Feature Toggles (aka Feature Flags) in your Laravel applications:

A Feature flag is sometimes also referred to as a feature toggle or feature switch. Ultimately it’s a coding strategy to be used along with source control to make it easier to continuous integrate and continuous deployment. The idea of the flags works by essentially safe guarding sections of code from executing if a feature flag isn’t in a switched on state.

This package aims to make implementing such flags across your application a great deal easier by providing solutions that work with not only your code but your routes, blade files, task scheduling and validations.

This package provides configuration with multiple storage options, and helps you in various contexts:

  • Blade Views
  • Routing Middleware
  • Validation Rules
  • Task Scheduling
  • Artisan Commands
  • Custom PHP logic

With this package you can use the provides Features facade or service to do things like check if a feature is on or off:

Features::accessible('my-feature') // returns true or false

The same check within a blade template would look like the following:

@feature('my-feature')
    <p>Your feature flag is turned on.
@endfeature

@feature('my-feature', false)
    <p>Your feature flag is turned off.
@endfeature

Using the same feature name, you could toggle a route on/off using the provided middleware:

Route::get('/', 'SomeController@get')
    ->middleware('feature:my-feature');

You can learn more about this package, get full installation instructions, and view the source code on GitHub at ylsideas/feature-flags.

Filed in: News

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Full Stack PHP Developer (Laravel)
Remote
MAPPEN
Senior Laravel Developer
Remote
ACTO
Senior Full-Stack Engineer
[REMOTE: USA Only]
Curricula
Developers for B2B eCommerce SaaS, AWS serverless, Laravel, Vue, Python
Remote, full time EU only
ES Tech Group
Senior PHP Developer (Laravel)
Remote
The Interaction Design Foundation