PHP code example of rubix / client

1. Go to this page and download the library: Download rubix/client 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/ */

    

rubix / client example snippets


public predict(Dataset $dataset) : array

use Rubix\Client\RESTClient;

$client = new RESTClient('127.0.0.1', 8080);

// Import a dataset

$predictions = $client->predict($dataset);

public proba(Dataset $dataset) : array

public score(Dataset $dataset) : array

public predictAsync(Dataset $dataset) : Promise

$promise = $client->predictAsync($dataset);

// Do something else

$predictions = $promise->wait();

public probaAsync(Dataset $dataset) : Promise

public scoreAsync(Dataset $dataset) : Promise

use Rubix\Client\RESTClient;
use Rubix\Client\HTTP\Middleware\BasicAuthenticator;
use Rubix\Client\HTTP\Middleware\CompressRequestBody;
use Rubix\Client\HTTP\Middleware\BackoffAndRetry;
use Rubix\Client\HTTP\Encoders\Gzip;

$client = new RESTClient('127.0.0.1', 443, true, [
	new BasicAuthenticator('user', 'password'),
	new CompressRequestBody(new Gzip(1)),
	new BackoffAndRetry(),
], 0.0, true);

use Rubix\Client\HTTP\Middleware\BackoffAndRetry;

$middleware = new BackoffAndRetry(5, 0.5);

use Rubix\Client\HTTP\Middleware\BasicAuthenticator;

$middleware = new BasicAuthenticator('morgan', 'secret');

use Rubix\Client\HTTP\Middleware\CompressRequestBody;

$middleware = new CompressRequestBody(5, 65535);

use Rubix\Client\HTTP\Middleware\SharedtokenAuthenticator;

$middleware = new SharedTokenAuthenticator('secret');