PHP code example of daylerees / scientist-laravel

1. Go to this page and download the library: Download daylerees/scientist-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

daylerees / scientist-laravel example snippets




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,

    ],
    
];



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,

    ],

];



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



use Scientist\Laboratory;

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