PHP 8.6.0 Beta 2 available for testing

Yar_Client::__construct

(PECL yar >= 1.0.0)

Yar_Client::__constructCreate a client

Description

final public function Yar_Client::__construct(string $uri, ?array $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://host/api/");

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

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top