Yar_Client::__construct

Create a client

Description

final public Yar_Client::__construct(string $uri, arraynull $options = null)

Creates a Yar_Client for the RPC service located at uri.

Parameters

uri
Address of the RPC service. The protocol is derived from the scheme: http:// and https:// select the HTTP transport, tcp:// selects the TCP transport, and unix:// selects the Unix socket transport.
options
An array of client options, keyed by the YAR_OPT_* constants, equivalent to calling Yar_Client::setOpt for each entry. Invalid options are silently skipped.

Return Values

A new Yar_Client instance.

Errors/Exceptions

If the URI does not start with a supported scheme, a Yar_Client_Protocol_Exception is thrown.

Examples

Example #1 Yar_Client::__construct example

<?php
$client = new Yar_Client("http://api.example.com/operator.php");

/* with options */
$client = new Yar_Client("http://api.example.com/operator.php", [
    YAR_OPT_TIMEOUT => 1000,
    YAR_OPT_PACKAGER => "json",
]);
?>

See Also

  • Yar_Client::call
  • Yar_Client::setOpt