PHP Class lithium\net\socket\Curl

This curl adapter provides the required method implementations of the abstract Socket class for open, close, read, write, timeout eof and encoding. Your PHP installation must have been compiled with the --with-curl[=DIR] directive. If this is not the case, you must either recompile PHP with the proper configuration flags to enable curl, or you may use the Stream adapter that is also included with the Lithium core.
See also: lithium\net\socket\Stream
Inheritance: extends lithium\net\Socket
Datei anzeigen Open project: unionofrad/lithium Class Usage Examples

Public Properties

Property Type Description
$options array Contains options that will be passed to curl_setopt_array before read and write operations. These options should be set by using the set method.

Public Methods

Method Description
__construct ( array $config = [] ) : void Constructor.
close ( ) : boolean Closes the curl connection.
encoding ( string $charset ) encoding() is currently unimplemented for this socket adapter
eof ( ) : null EOF is unimplemented for this socket adapter.
open ( array $options = [] ) : mixed Opens a curl connection and initializes the internal resource handle.
read ( ) : mixed Reads data from the curl connection.
set ( array $flags, array $value = null ) : void Sets the options to be used in subsequent curl requests.
timeout ( integer $time ) : boolean A convenience method to set the curl CURLOPT_CONNECTTIMEOUT setting for the current connection. This determines the number of seconds to wait while trying to connect.
write ( array | Message $data = null ) : boolean Writes data to curl options

Method Details

__construct() public method

Constructor.
public __construct ( array $config = [] ) : void
$config array
return void

close() public method

Closes the curl connection.
public close ( ) : boolean
return boolean True on closed connection

encoding() public method

encoding() is currently unimplemented for this socket adapter
public encoding ( string $charset )
$charset string

eof() public method

EOF is unimplemented for this socket adapter.
public eof ( ) : null
return null

open() public method

Opens a curl connection and initializes the internal resource handle.
public open ( array $options = [] ) : mixed
$options array update the config settings if $options['options'] exists, will be passed to $this->set()
return mixed Returns `false` if the socket configuration does not contain the `'scheme'` or `'host'` settings, or if configuration fails, otherwise returns a resource stream.

read() public method

The read method will utilize the curl options that have been set.
public read ( ) : mixed
return mixed Boolean false if the resource handle is unavailable, and the result of `curl_exec` otherwise.

set() public method

Sets the options to be used in subsequent curl requests.
public set ( array $flags, array $value = null ) : void
$flags array If $values is an array, $flags will be used as the keys to an associative array of curl options. If $values is not set, then $flags will be used as the associative array.
$value array If set, this array becomes the values for the associative array of curl options.
return void

timeout() public method

Note: A value of 0 may be used to specify an indefinite wait time.
public timeout ( integer $time ) : boolean
$time integer The timeout value in seconds
return boolean False if the resource handle is unavailable or the option could not be set, true otherwise.

write() public method

Writes data to curl options
public write ( array | Message $data = null ) : boolean
$data array | lithium\net\Message
return boolean

Property Details

$options public_oe property

Contains options that will be passed to curl_setopt_array before read and write operations. These options should be set by using the set method.
See also: lithium\net\socket\Curl::set()
public array $options
return array