2017 © Pedro Peláez
 

library laravel-rollout

A package to integrate rollout into your Laravel project.

image

jaspaul/laravel-rollout

A package to integrate rollout into your Laravel project.

  • Friday, February 23, 2018
  • by Jaspaul
  • Repository
  • 1 Watchers
  • 13 Stars
  • 8,536 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 4 Open issues
  • 9 Versions
  • 10 % Grown

The README.md

Laravel Rollout

A Laravel package for opensoft/rollout, (*1)

Build Status Coverage Status Code Climate, (*2)

Installation

Composer

composer require jaspaul/laravel-rollout

Configuring the Service Provider

Package discovery will configure the service provider automatically., (*3)

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., (*4)

Setting up Persistent Storage

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

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:, (*6)

<?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., (*7)

<?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:, (*8)

laravel-rollout.php, (*9)

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

Commands

Add Group

php artisan rollout:add-group {feature} {group}, (*10)

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

Add User

php artisan rollout:add-user {feature} {user}, (*12)

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

Create

php artisan rollout:create {feature}, (*14)

Swap {feature} with the name of the feature you'd like to create a feature flag for., (*15)

Deactivate

php artisan rollout:deactivate {feature}, (*16)

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

Delete

php artisan rollout:delete {feature}, (*18)

Swap {feature} with the name of the feature you'd like to permanently delete from rollout., (*19)

Everyone

php artisan rollout:everyone {feature}, (*20)

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

List

php artisan rollout:list, (*22)

, (*23)

Percentage

php artisan rollout:percentage {feature} {percentage}, (*24)

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., (*25)

Remove Group

php artisan rollout:remove-group {feature} {group}, (*26)

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

Remove User

php artisan rollout:remove-user {feature} {user}, (*28)

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., (*29)

The Versions