PHP Class Elastica\Connection

Author: Nicolas Ruflin ([email protected])
Inheritance: extends Param
Show file Open project: ruflin/elastica Class Usage Examples

Public Methods

Method Description
__construct ( array $params = [] ) Creates a new connection object. A connection is enabled by default.
addConfig ( string $key, mixed $value )
create ( Connection | array $params = [] ) : self
getConfig ( string $key = '' ) : array | string Returns a specific config key or the whole config array if not set.
getConnectTimeout ( ) : integer
getHost ( ) : string
getPassword ( ) : string
getPath ( ) : string
getPort ( ) : integer
getProxy ( ) : string | null
getTimeout ( ) : integer
getTransport ( ) : string | array
getTransportObject ( ) : AbstractTransport Returns an instance of the transport type.
getUsername ( ) : string
hasCompression ( ) : boolean
hasConfig ( string $key ) : boolean
isEnabled ( ) : boolean
isPersistent ( ) : boolean
setCompression ( boolean $compression = null )
setConfig ( array $config )
setConnectTimeout ( integer $timeout ) Number of seconds after a connection timeout occurs for every request during the connection phase.
setEnabled ( boolean $enabled = true ) Enables a connection.
setHost ( string $host )
setPath ( string $path )
setPort ( integer $port )
setProxy ( string | null $proxy ) Set proxy for http connections. Null is for environmental proxy, empty string to disable proxy and proxy string to set actual http proxy.
setTimeout ( integer $timeout )
setTransport ( string | array $transport )

Method Details

__construct() public method

Creates a new connection object. A connection is enabled by default.
public __construct ( array $params = [] )
$params array OPTIONAL Connection params: host, port, transport, timeout. All are optional

addConfig() public method

public addConfig ( string $key, mixed $value )
$key string
$value mixed

create() public static method

public static create ( Connection | array $params = [] ) : self
$params Connection | array Params to create a connection
return self

getConfig() public method

Returns a specific config key or the whole config array if not set.
public getConfig ( string $key = '' ) : array | string
$key string Config key
return array | string Config value

getConnectTimeout() public method

public getConnectTimeout ( ) : integer
return integer Connection timeout in seconds

getHost() public method

public getHost ( ) : string
return string Host

getPassword() public method

public getPassword ( ) : string
return string Password

getPath() public method

public getPath ( ) : string
return string

getPort() public method

public getPort ( ) : integer
return integer Server port

getProxy() public method

public getProxy ( ) : string | null
return string | null Host

getTimeout() public method

public getTimeout ( ) : integer
return integer Connection timeout in seconds

getTransport() public method

public getTransport ( ) : string | array
return string | array

getTransportObject() public method

Returns an instance of the transport type.
public getTransportObject ( ) : AbstractTransport
return Elastica\Transport\AbstractTransport Transport object

getUsername() public method

public getUsername ( ) : string
return string User

hasCompression() public method

public hasCompression ( ) : boolean
return boolean

hasConfig() public method

public hasConfig ( string $key ) : boolean
$key string
return boolean

isEnabled() public method

public isEnabled ( ) : boolean
return boolean True if enabled

isPersistent() public method

public isPersistent ( ) : boolean
return boolean Returns true if connection is persistent. True by default

setCompression() public method

public setCompression ( boolean $compression = null )
$compression boolean

setConfig() public method

public setConfig ( array $config )
$config array

setConnectTimeout() public method

Use a small value if you need a fast fail in case of dead, unresponsive or unreachable servers (~5 sec). Set to zero to switch to the default built-in connection timeout (300 seconds in curl).
See also: http://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
public setConnectTimeout ( integer $timeout )
$timeout integer Connect timeout in seconds

setEnabled() public method

Enables a connection.
public setEnabled ( boolean $enabled = true )
$enabled boolean OPTIONAL (default = true)

setHost() public method

public setHost ( string $host )
$host string

setPath() public method

public setPath ( string $path )
$path string

setPort() public method

public setPort ( integer $port )
$port integer

setProxy() public method

Set proxy for http connections. Null is for environmental proxy, empty string to disable proxy and proxy string to set actual http proxy.
See also: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY
public setProxy ( string | null $proxy )
$proxy string | null

setTimeout() public method

public setTimeout ( integer $timeout )
$timeout integer Timeout in seconds

setTransport() public method

public setTransport ( string | array $transport )
$transport string | array