2017 © Pedro Peláez
 

library scientist-laravel

Allow the Scientist library to be used with the Laravel PHP framework.

image

daylerees/scientist-laravel

Allow the Scientist library to be used with the Laravel PHP framework.

  • Saturday, February 6, 2016
  • by daylerees
  • Repository
  • 1 Watchers
  • 39 Stars
  • 76 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Scientist, (*1)

Scientist for Laravel

Packagist Version Packagist, (*2)

Allow the Scientist library to be used with the Laravel PHP framework., (*3)

Installation

Require the latest version of Scientist Laravel using Composer., (*4)

composer require daylerees/scientist-laravel

Next, add the service provider to the providers section of config/app.php in your Laravel project., (*5)

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Autoloaded Service Providers
    |--------------------------------------------------------------------------
    |
    | The service providers listed here will be automatically loaded on the
    | request to your application. Feel free to add your own services to
    | this array to grant expanded functionality to your applications.
    |
    */

    'providers' => [

        /*
         * Application Service Providers...
         */
        App\Providers\AppServiceProvider::class,
        App\Providers\AuthServiceProvider::class,
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,

        Scientist\Laravel\ScientistServiceProvider::class,

    ],

];

Finally, register the Facade within the aliases section of config/app.php., (*6)

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Class Aliases
    |--------------------------------------------------------------------------
    |
    | This array of class aliases will be registered when this application
    | is started. However, feel free to register as many as you wish as
    | the aliases are "lazy" loaded so they don't hinder performance.
    |
    */

    'aliases' => [

        'URL'       => Illuminate\Support\Facades\URL::class,
        'Validator' => Illuminate\Support\Facades\Validator::class,
        'View'      => Illuminate\Support\Facades\View::class,

        'Scientist' => Scientist\Laravel\Facade::class,

    ],

];

You're good to go!, (*7)

Usage

You can access the Scientist Laboratory through the Scientist facade., (*8)

<?php

$value = Scientist::experiment('foo')
    ->control($controlCallback)
    ->trial('First trial.', $trialCallback)
    ->run();

Or, inject the Laboratory into a container resolved class or controller action., (*9)

<?php

use Scientist\Laboratory;

class FooController extends Controller
{
    public function index(Laboratory $laboratory)
    {
        return $laboratory->experiment('foo')
            ->control(function() { ... })
            ->trial('First trial.', function() { ... })
            ->run();
    }
}

See the Scientist documentation for more information!, (*10)

Enjoy!, (*11)

The Versions

06/02 2016

dev-master

9999999-dev

Allow the Scientist library to be used with the Laravel PHP framework.

  Sources   Download

MIT

The Requires

 

laravel test framework testing experiment scientist dayle

06/02 2016

0.1.1-alpha

0.1.1.0-alpha

Allow the Scientist library to be used with the Laravel PHP framework.

  Sources   Download

MIT

The Requires

 

laravel test framework testing experiment scientist dayle