Download the PHP package partechgss/laravel-feature-toggle without Composer

On this page you can find all versions of the php package partechgss/laravel-feature-toggle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-feature-toggle

Abstract Feature Flags from Providers

This package allows you to implement feature flags in Laravel. Right now the only supported implementation is split.io.

Basic Usage

Change Behavior Based on a Flag

use PartechGSS\Laravel\FeatureToggle\Contracts\FeatureToggleClient;

$client = resolve(FeatureToggleClient::class);
switch ($client->getTreatment('my_flag')) {
    case "on":
        do_a_thing();
        break;

    default:
        do_another_thing();
        break;
}

Retrieve Configuration Attached to a Treatment

$treatmentWithConfig = $client->getTreatmentWithConfig('my_flag');
$treatment = $treatmentWithConfig['treatment'];
$config = $treatmentWithConfig['config'];
set_some_css_options($config);

Retrieve Multiple Flags in a Batch

$treatments = $client->getTreatments(['my_flag', 'another_flag']);
switch($treatments['my_flag']) {
    ...
}

Retrieve Configurations in a Batch

$treatmentsWithConfig = $client->getTreatmentsWithConfig('my_flag');
$treatment = $treatmentsWithConfig['my_flag']['treatment'];
$config = $treatmentsWithConfig['my_flgag']['config'];
set_some_css_options($config);

Installation

You can install the package via Composer:

composer require partechgss/laravel-feature-toggles

Configuration

Config File

Looks for config/feature-toggle.php. To install the default one:

php artisan vendor:publish

Middleware

You need to set the toggle "key" somewhere. This is usually something like a user's email address, used to decide which treatment the user gets for a particular flag. This package provides middleware that automatically sets the key based on the user's email addesss. This must be run after your authentication middleware, so, first make it available as route middleware and set the priority in your app/Http/Kernel.php.

use PartechGSS\Laravel\FeatureToggle\Middleware\SetFeatureToggleKeyFromUserEmail;
protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'feature-toggle' => SetFeatureToggleKeyFromUserEmail::class,
];
protected $middlewarePriority = [
    \App\Http\Middleware\Authenticate::class,
    SetFeatureToggleKeyFromUserEmail::class,
];

Execute as Route Middleware

# routes/api.php
Route::middleware(['auth:api', 'feature-toggle'])->group(function() {
    ...,
});

Execute via Route Middleware Groups

# app/Http/Kernel.php
protected $middlewareGroups = [
    'web' => [
        ...,
        'feature-toggle',
    ],

    'api' => [
        \Barryvdh\Cors\HandleCors::class,
        'throttle:60,1',
        'bindings',
        'feature-toggle',
    ],
];

Testing

This Project

composer test

Your Project

The SplitIO SDK throws errors when it can't find a configuration file in localhost mode. To work around that, create a dummy local split.yaml file and ask the factory to load it. For example, you can set SPLITIO_SPLIT_FILE in your testing environment to point to your file:

# .env.testing
SPLITIO_SPLIT_FILE=tests/__data__/split.yaml

This assumes a file like this one at tests/__data__/split.yaml:

- hello_world:
  treatment: off
- hello_world:
  treatment: on
  keys: "[email protected]"

All versions of laravel-feature-toggle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4
splitsoftware/split-sdk-php Version 6.2.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package partechgss/laravel-feature-toggle contains the following files

Loading the files please wait ....