Giter VIP home page Giter VIP logo

laravel-rollout's Introduction

Laravel Rollout

A Laravel package for opensoft/rollout

Build Status Coverage Status Code Climate

Installation

Composer

composer require jaspaul/laravel-rollout

Configuring the Service Provider

Package discovery will configure the service provider automatically.

Setting up Storage

Publish the Configuration

php artisan vendor:publish --provider 'Jaspaul\LaravelRollout\ServiceProvider'

Setting up a Cache

If you intend to use cache to store the settings for rollout, be sure to enable the cache for your Laravel application. Note if you are using the cache, a cache clear during deployment will cause your rollout settings to be purged. If you require persistence for these settings use the option below.

Setting up Persistent Storage

This will allow you to have rollout settings be persisted even if you clear the application cache for every deployment.

Running the Migrations
php artisan migrate
Configuring your Environment
ROLLOUT_STORAGE=database
ROLLOUT_TABLE=rollout

Implementing Interfaces

User

Your rollout users must implement the \Jaspaul\LaravelRollout\Contracts\User interface. Often this will be your main user object:

<?php

use Jaspaul\LaravelRollout\Helpers\User as Contract;

class User implements Contract
{
    /**
     * @return string
     */
    public function getRolloutIdentifier()
    {
        return $this->id;
    }
}

Group

Your rollout groups must implement the \Jaspaul\LaravelRollout\Contracts\Group interface.

<?php

use Jaspaul\LaravelRollout\Contracts\Group;

class BetaUsersGroup implements Group
{
    /**
     * The name of the group.
     *
     * @return string
     */
    public function getName(): string
    {
        return 'beta-users';
    }

     /**
     * Defines the rule membership in the group.
     *
     * @return boolean
     */
    public function hasMember($user = null): bool
    {
        if (!is_null($user)) {
            return $user->hasOptedIntoBeta();
        }

        return false;
    }
}

and you should update your local laravel-rollout.php configuration to include the group in the groups array:

laravel-rollout.php

return [
    ...
    'groups' => [
        BetaUsersGroup::class
    ],
    ...
]

Commands

Add Group

php artisan rollout:add-group {feature} {group}

Swap {feature} with the name of the feature, and {group} with the name you defined in the group class.

Add User

php artisan rollout:add-user {feature} {user}

Swap {feature} with the name of the feature, and {user} with a unique identifier for the user in your system.

Create

php artisan rollout:create {feature}

Swap {feature} with the name of the feature you'd like to create a feature flag for.

Deactivate

php artisan rollout:deactivate {feature}

Swap {feature} with the name of the feature you'd like to deactivate globally. Note this will also reset the user whitelist.

Delete

php artisan rollout:delete {feature}

Swap {feature} with the name of the feature you'd like to permanently delete from rollout.

Everyone

php artisan rollout:everyone {feature}

Swap {feature} with the name of the feature you'd like to rollout to 100% of your user base.

List

php artisan rollout:list

Percentage

php artisan rollout:percentage {feature} {percentage}

Swap {feature} with the name of the feature you'd like to rollout, and {percentage} with the percentage of users to rollout the feature to.

Remove Group

php artisan rollout:remove-group {feature} {group}

Swap {feature} with the name of the feature, and {group} with the name you defined in the group class.

Remove User

php artisan rollout:remove-user {feature} {user}

Swap {feature} with the name of the feature, and {user} with a unique identifier for the user in your system to remove the feature from.

laravel-rollout's People

Contributors

jaspaul avatar bramdevries avatar spamoom avatar datashaman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.