Download the PHP package rubix/client without Composer
On this page you can find all versions of the php package rubix/client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package client
Short Description The PHP client SDK for Rubix ML Server.
License MIT
Homepage https://github.com/RubixML/Client
Informations about the package client
Rubix Client
The PHP client SDK for Rubix ML Server.
Installation
Install Rubix Client SDK using Composer:
Requirements
- PHP 7.4 or above
Documentation
The latest documentation can be found below.
Table of Contents
- Clients
- REST Client
- Client Middleware
- Backoff and Retry
- Basic Authenticator
- Compress Request Body
- Shared Token Authenticator
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:
Calculate the joint probabilities of each sample in a dataset:
Calculate the anomaly scores of each sample in a dataset:
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+ 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.
Return a promise for the probabilities predicted by the model:
Return a promise for the anomaly scores predicted by the model:
REST Client
The REST Client communicates with the HTTP Server through the JSON REST API it exposes.
Interfaces: AsyncClient
Parameters
# | Param | Default | Type | Description |
---|---|---|---|---|
1 | host | '127.0.0.1' | string | The IP address or hostname of the server. |
2 | port | 8000 | int | The network port that the HTTP server is running on. |
3 | secure | false | bool | Should we use an encrypted HTTP channel (HTTPS)? |
4 | middlewares | array | The stack of client middleware to run on each request/response. | |
5 | timeout | float | The number of seconds to wait before giving up on the request. | |
6 | verify certificate | true | bool | Should we try to verify the server's TLS certificate? |
Example
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 Shared Token Authenticator.
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
# | Param | Default | Type | Description |
---|---|---|---|---|
1 | max retries | 3 | int | The maximum number of times to retry the request before giving up. |
2 | initial delay | 0.5 | float | The number of seconds to delay between retries before exponential backoff is applied. |
Example
Basic Authenticator (Client Side)
Adds the necessary authorization headers to the request using the Basic scheme.
Parameters
# | Param | Default | Type | Description |
---|---|---|---|---|
1 | username | string | The user's name. | |
2 | password | string | The user's password. |
Example
Compress Request Body
Apply the Gzip compression algorithm to the request body.
Parameters
# | Param | Default | Type | Description |
---|---|---|---|---|
1 | level | 5 | int | The compression level between 0 and 9 with 0 meaning no compression. |
2 | threshold | 65535 | int | The minimum size of the request body in bytes in order to be compressed. |
Example
Shared Token Authenticator (Client Side)
Adds the necessary authorization headers to the request using the Bearer scheme.
Parameters
# | Param | Default | Type | Description |
---|---|---|---|---|
1 | token | string | The shared token to authenticate the request. |
Example
License
The code is licensed CC BY-NC 4.0.
All versions of client with dependencies
guzzlehttp/guzzle Version ^7.2
guzzlehttp/psr7 Version ^1.7
psr/http-message Version ^1.0
rubix/ml Version ^2.0
symfony/polyfill-php80 Version ^1.17