Feature Switching made easy in Laravel 5

Overview

Feature Switching (made easy) for Laravel

Need to wrap new features for dev and production? Use a directive in the view or alias in the controller

There's great libraries in Java and other languages, but I found a real lack of good libraries to do this in PHP, so I've created my own.

Installation

Add the following line to the require section of composer.json:

{
    "require": {
        "jonathanbird/feature-switch": "dev-master"
    }
}

or composer require jonathanbird/feature-switch

Setup

  1. Add 'JonathanBird\FeatureSwitch\FeatureSwitchServiceProvider', to the service provider list in app/config/app.php.
  2. Run php artisan vendor:publish to publish the features config file to config/feature-switch/features.php

Usage

  1. In the view, you can use the directive @feature('feature_name') something @endfeature (note @else also works for when a feature is not enabled)
  2. In your controller or anywhere, simply add use Feature; to the top of your file and use the alias Feature::isEnabled('feature_one') which returns a boolean value
  3. To add features, add your feature name and boolean value to config/feature-switch/features.php

Why would I use this over git merging?

If you have multiple environments (e.g. three test environments, staging and production) and you want to have the code base in a state of continuous deployment, then you may wish to branch your feature, wrap it within feature switch, merge it in to master branch, and when it gets to staging or production and you realise there's a bug, you can simply switch the feature off without it causing an issue rather than having to remove code from a merge. This is also works well for launching a feature as it's a simple on/off switch - simply git ignore the features.php file to have a different one in each environment.

Issues

If you find an issue, please report it. If it's something you can fix, fork the project and use a pull request as it'll be much quicker.

You might also like...
A blog system made with Laravel ๐Ÿ“ฆ
A blog system made with Laravel ๐Ÿ“ฆ

This project utilizes all the tools avaiable on Laravel 9. It has a complete auth system, the option to create posts and save static image files.

A collection of pre-made simple Laravel Blade form components.
A collection of pre-made simple Laravel Blade form components.

Laravel Form Components Library A collection of pre-made simple Laravel Blade form components. Installation & setup You can install the package via co

Observe (and react to) attribute changes made on Eloquent models.
Observe (and react to) attribute changes made on Eloquent models.

Laravel Attribute Observer Requirements PHP: 7.4+ Laravel: 7+ Installation You can install the package via composer: composer require alexstewartja/la

Public API for the project coding.events. Made in PHP 8.0 with Lumen 8, PHP-FPM, NGINX and MySQL 8.
Public API for the project coding.events. Made in PHP 8.0 with Lumen 8, PHP-FPM, NGINX and MySQL 8.

coding.events API Uma API feita apenas para passar o tempo, montando uma API para o site coding.events. Sinta-se livre para usar esse cรณdigo como es

A Slack Invitator made with Lumen Framework.

Lumen - Slackin A Slack Invitator made with Lumen Framework and inspired by rauchg/slackin. That application uses some of my awesome packages: Badge P

Email-flooder - A CLI flooder e-mail tool, made in PHP.
Email-flooder - A CLI flooder e-mail tool, made in PHP.

E-mail flooder (PHP 8.0.13) You can send emails to any server, however the request must come from Gmail. (Remember to enable less secure apps to be ab

Integrate likes, bookmarks, favorites, reactions and custom made marks into your application
Integrate likes, bookmarks, favorites, reactions and custom made marks into your application

Laravel Markable This package allows you to easily add the markable feature to your application, as for example likes, bookmarks, favorites and so on.

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models.

Laravel Wrapper for PostgreSQL's Geo-Extension Postgis Features Work with geometry classes instead of arrays. $model-myPoint = new Point(1,2); //lat

Comments
  • Feature request: enable feature for subset of users

    Feature request: enable feature for subset of users

    Hey,

    Great library - I have been looking for a Laravel package that does this for some time. I have a feature request but not sure if it is in the scope of this package.

    It would be great to be able to roll out a feature to a certain % of users. Say 1% of users initially and then scale that up to 100% as you become more confident you haven't introduced any bugs.

    Thoughts?

    enhancement help wanted 
    opened by jbardnz 4
Owner
Jonathan Bird
Senior Software Engineer & Architect. Problem solver. Laravel developer.
Jonathan Bird
Nebula is a minimalistic and easy to use administration tool for Laravel applications, made with Laravel, Alpine.js, and Tailwind CSS.

Nebula Nebula is a minimalistic and easy to use administration tool for Laravel applications, made with Laravel, Alpine.js, and Tailwind CSS. Nebula m

Nebula 228 Nov 11, 2022
An Easy, Customizable & Open Source Robux Rewards Website Made With Laravel

RbxDream - Robux Earning Rewards Website Coming Soon Current repo not stable. This is an open source Robux rewards site. Understanding Core Concepts T

Underground 3 Feb 15, 2022
Eloquent model-caching made easy.

Model Caching for Laravel Supporting This Package This is an MIT-licensed open source project with its ongoing development made possible by the suppor

GeneaLabs, LLC 2k Dec 26, 2022
this package can help you to test race condition in Laravel Feature Test

Laravel Async Testing this package can help you to test race condition in Laravel Feature Test Requirements Laravel versions 5.7, 6.x, 7.x and 8.x PHP

Recca Tsai 61 Nov 5, 2022
Cascade delete and restore when using the Laravel or Lumen SoftDeletes feature.

Cascade delete and restore when using the Laravel or Lumen SoftDeletes feature.

Asked.io 669 Nov 30, 2022
An opinionated feature flags package for Laravel

This package provides an opinionated API for implementing feature flags in your Laravel applications. It supports application-wide features as well as model specific feature flags.

Ryan Chandler 157 Nov 24, 2022
A package that adds view-composer like feature to Inertia.js Laravel adapter

Kinetic A package that adds view-composer like feature to Inertia.js Laravel adapter. Use to be able to share props based on the Inertia component nam

Marvin Quezon 76 Dec 12, 2022
Easily interact and control your feature flags from Filament

Easily interact and control your feature flags from Filament

Ryan Chandler 32 Nov 29, 2022
This is a simple url bot validator made with laravel and react

?? This is a simple URL validator. Used Technologies React - Javascript framework Laravel - PHP framework Mysql - Relational database Installation Ins

Vanderson Telema 1 Oct 27, 2021
๐Ÿš€ API for ticketing system application made in laravel ๐Ÿš€

Ticket System Api Description: It is a basic system in which an employee logs in, can create, update and delete tickets, can create an employee, and t

Luis J. Santana 3 Oct 21, 2022