PHPackages                             rubix/client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. rubix/client

ActiveLibrary[API Development](/categories/api)

rubix/client
============

The PHP client SDK for Rubix ML Server.

2.0.0(2y ago)54821MITPHPPHP &gt;=7.4

Since Jan 9Pushed 2y ago3 watchersCompare

[ Source](https://github.com/RubixML/Client)[ Packagist](https://packagist.org/packages/rubix/client)[ Docs](https://github.com/RubixML/Client)[ GitHub Sponsors](https://github.com/sponsors/andrewdalpino)[ RSS](/packages/rubix-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (10)Versions (3)Used By (0)

Rubix Client
============

[](#rubix-client)

The PHP client SDK for Rubix ML Server.

Installation
------------

[](#installation)

Install Rubix Client SDK using [Composer](https://getcomposer.org/):

```
$ composer require rubix/client
```

Requirements
------------

[](#requirements)

- [PHP](https://php.net/manual/en/install.php) 7.4 or above

Documentation
-------------

[](#documentation)

The latest documentation can be found below.

### Table of Contents

[](#table-of-contents)

- [Clients](#clients)
    - [REST Client](#rest-client)
- [Client Middleware](#client-middleware)
    - [Backoff and Retry](#backoff-and-retry)
    - [Basic Authenticator](#basic-authenticator-client-side)
    - [Compress Request Body](#compress-request-body)
    - [Shared Token Authenticator](#shared-token-authenticator-client-side)

---

### Clients

[](#clients)

Clients allow you to communicate directly with a model server using a friendly object-oriented interface inside your PHP applications. Under the hood, clients handle all the networking communication and content negotiation for you so you can write programs *as if* the model was directly accessible in your applications.

Return the predictions from the model:

```
public predict(Dataset $dataset) : array
```

```
use Rubix\Client\RESTClient;

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

// Import a dataset

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

Calculate the joint probabilities of each sample in a dataset:

```
public proba(Dataset $dataset) : array
```

Calculate the anomaly scores of each sample in a dataset:

```
public score(Dataset $dataset) : array
```

### Async Clients

[](#async-clients)

Clients that implement the Async Client interface have asynchronous versions of all the standard client methods. All asynchronous methods return a [Promises/A+](https://promisesaplus.com/) object that resolves to the return value of the response. Promises allow you to perform other work while the request is processing or to execute multiple requests in parallel. Calling the `wait()` method on the promise will block until the promise is resolved and return the value.

```
public predictAsync(Dataset $dataset) : Promise
```

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

// Do something else

$predictions = $promise->wait();
```

Return a promise for the probabilities predicted by the model:

```
public probaAsync(Dataset $dataset) : Promise
```

Return a promise for the anomaly scores predicted by the model:

```
public scoreAsync(Dataset $dataset) : Promise
```

### REST Client

[](#rest-client)

The REST Client communicates with the [HTTP Server](#http-server) through the JSON REST API it exposes.

Interfaces: [Client](#clients), [AsyncClient](#async-clients)

#### Parameters

[](#parameters)

\#ParamDefaultTypeDescription1host'127.0.0.1'stringThe IP address or hostname of the server.2port8000intThe network port that the HTTP server is running on.3securefalseboolShould we use an encrypted HTTP channel (HTTPS)?4middlewaresarrayThe stack of client middleware to run on each request/response.5timeoutfloatThe number of seconds to wait before giving up on the request.6verify certificatetrueboolShould we try to verify the server's TLS certificate?**Example**

```
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);
```

### Client Middleware

[](#client-middleware)

Similarly to Server middleware, client middlewares are functions that hook into the request/response cycle but from the client end. Some of the server middlewares have accompanying client middleware such as [Basic Authenticator](#basic-authenticator) and [Shared Token Authenticator](#shared-token-authenticator).

### Backoff and Retry

[](#backoff-and-retry)

The Backoff and Retry middleware handles Too Many Requests (429) and Service Unavailable (503) responses by retrying the request after waiting for a period of time to avoid overloading the server even further. An acceptable backoff period is gradually achieved by multiplicatively increasing the delay between retries.

#### Parameters

[](#parameters-1)

\#ParamDefaultTypeDescription1max retries3intThe maximum number of times to retry the request before giving up.2initial delay0.5floatThe number of seconds to delay between retries before exponential backoff is applied.**Example**

```
use Rubix\Client\HTTP\Middleware\BackoffAndRetry;

$middleware = new BackoffAndRetry(5, 0.5);
```

### Basic Authenticator (Client Side)

[](#basic-authenticator-client-side)

Adds the necessary authorization headers to the request using the Basic scheme.

#### Parameters

[](#parameters-2)

\#ParamDefaultTypeDescription1usernamestringThe user's name.2passwordstringThe user's password.**Example**

```
use Rubix\Client\HTTP\Middleware\BasicAuthenticator;

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

### Compress Request Body

[](#compress-request-body)

Apply the Gzip compression algorithm to the request body.

#### Parameters

[](#parameters-3)

\#ParamDefaultTypeDescription1level5intThe compression level between 0 and 9 with 0 meaning no compression.2threshold65535intThe minimum size of the request body in bytes in order to be compressed.**Example**

```
use Rubix\Client\HTTP\Middleware\CompressRequestBody;

$middleware = new CompressRequestBody(5, 65535);
```

### Shared Token Authenticator (Client Side)

[](#shared-token-authenticator-client-side)

Adds the necessary authorization headers to the request using the Bearer scheme.

#### Parameters

[](#parameters-4)

\#ParamDefaultTypeDescription1tokenstringThe shared token to authenticate the request.**Example**

```
use Rubix\Client\HTTP\Middleware\SharedtokenAuthenticator;

$middleware = new SharedTokenAuthenticator('secret');
```

License
-------

[](#license)

The code is licensed [MIT](LICENSE) and the documentation is licensed [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~617 days

Total

2

Last Release

972d ago

Major Versions

0.0.1-beta → 2.0.02023-09-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/643b22cfe15a5f3ff42dc06ce98f1e5024b6e4578fc9627a058097f5046164d8?d=identicon)[andrewdalpino](/maintainers/andrewdalpino)

---

Top Contributors

[![andrewdalpino](https://avatars.githubusercontent.com/u/18690561?v=4)](https://github.com/andrewdalpino "andrewdalpino (5 commits)")

---

Tags

phpapicloudgraphqlinferenceaiserverREST APIJSON-APImachine learningpredictionmldistributedgraph-qlRubixphp mlrubixmlrubix mlphp machine learningphp aiMicroservicerest-clientinfrastructurerest-serverinference engineinference serverml infrastructuremodel servermodel deploymentml server

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rubix-client/health.svg)

```
[![Health](https://phpackages.com/badges/rubix-client/health.svg)](https://phpackages.com/packages/rubix-client)
```

###  Alternatives

[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

632.3k](/packages/rubix-server)[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[qwen-php/qwen-php-client

robust and community-driven PHP SDK library for seamless integration with the qwen AI API, offering efficient access to advanced AI and data processing capabilities

213.2k1](/packages/qwen-php-qwen-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
