daylerees/scientist-laravel

Allow the Scientist library to be used with the Laravel PHP framework.
84 55
Install
composer require daylerees/scientist-laravel
Latest Version:0.1.1-alpha
Laravel:5
License:MIT
Last Updated:Feb 5, 2016
Links: GitHub  ·  Packagist
Maintainer: daylerees

Scientist

Scientist for Laravel

Packagist Version Packagist

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

Installation

Require the latest version of Scientist Laravel using Composer.

composer require daylerees/scientist-laravel

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

<?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.

<?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!

Usage

You can access the Scientist Laboratory through the Scientist facade.

<?php

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

Or, inject the Laboratory into a container resolved class or controller action.

<?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!

Enjoy!

Related Packages

jampot5000/eloquent-scientist

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

11 0
pestphp/pest

The elegant PHP Testing Framework.

96,535,010 11,740
pestphp/pest-dev-tools

Dev requirements for Pest, The elegant PHP Testing Framework.

208,255 10
nckrtl/pestphp-monorepo

Pest with test-impact analysis for Composer monorepos and Git worktrees.

50,083 1
lightspeedphp/lightspeed

Run tests faster by splitting them across nodes.

79 2

Version History

Pre-releases (1)
Version Released Laravel License
0.1.1-alpha 5.* MIT