|
9 | 9 |
|
10 | 10 | The socket client use the stream extension from PHP, which is integrated into the core.
|
11 | 11 |
|
12 |
| -## Install |
13 |
| - |
14 |
| -Via Composer |
15 |
| - |
16 |
| -``` bash |
17 |
| -$ composer require php-http/socket-client |
18 |
| -``` |
19 |
| - |
20 | 12 | ## Features
|
21 | 13 |
|
22 | 14 | * TCP Socket Domain (tcp://hostname:port)
|
23 | 15 | * UNIX Socket Domain (unix:///path/to/socket.sock)
|
24 | 16 | * TLS / SSL Encyrption
|
25 | 17 | * Client Certificate (only for php > 5.6)
|
26 | 18 |
|
| 19 | +## Installation and Usage |
27 | 20 |
|
28 |
| -## Usage |
29 |
| - |
30 |
| -The SocketHttpClient class need a [message factory](https://github.com/php-http/message-factory) in order to work: |
31 |
| - |
32 |
| -```php |
33 |
| -$options = []; |
34 |
| -$client = new new Http\Socket\SocketHttpClient($messageFactory, $options); |
35 |
| -``` |
36 |
| - |
37 |
| -The `$options` array allow to configure the socket client. |
38 |
| - |
39 |
| - |
40 |
| -## Options |
41 |
| - |
42 |
| -Here is the list of available options: |
43 |
| - |
44 |
| - * remote_socket: Specify the remote socket where the library should send the request to |
45 |
| - |
46 |
| - Can be a tcp remote : tcp://hostname:port |
47 |
| - |
48 |
| - Can be a unix remote : unix://hostname:port |
49 |
| - |
50 |
| - Do not use a tls / ssl scheme, this is handle by the ssl option. |
51 |
| - |
52 |
| - If not set, the client will try to determine it from the request uri or host header. |
53 |
| - |
54 |
| - * timeout : Timeout in __milliseconds__ for writing request and reading response on the remote |
55 |
| - * ssl : Activate or deactivate the ssl / tls encryption |
56 |
| - * stream_context_options : Custom options for the context of the stream, same as [PHP stream context options](http://php.net/manual/en/context.php) |
57 |
| - |
58 |
| - As an example someone may want to pass a client certificate when using the ssl, a valid configuration for this |
59 |
| - use case would be: |
60 |
| - |
61 |
| - ```php |
62 |
| - $options = [ |
63 |
| - 'stream_context_options' => [ |
64 |
| - 'ssl' => [ |
65 |
| - 'local_cert' => '/path/to/my/client-certificate.pem' |
66 |
| - ] |
67 |
| - ] |
68 |
| - ] |
69 |
| - $client = new Http\Socket\SocketHttpClient($messageFactory, $options); |
70 |
| - ``` |
71 |
| - |
72 |
| - * stream_context_params : Custom parameters for the context of the stream, same as [PHP stream context parameters](http://php.net/manual/en/context.params.php) |
73 |
| - * write_buffer_size : When sending the request we need to bufferize the body, this option specify the size of this buffer, default is 8192, |
74 |
| - if you are sending big file with your client it may be interesting to have a bigger value in order to increase performance. |
75 |
| - |
| 21 | +[Read the documentation at http://docs.php-http.org/en/latest/clients/socket-client.html](http://docs.php-http.org/en/latest/clients/socket-client.html) |
76 | 22 |
|
77 | 23 | ## Testing
|
78 | 24 |
|
|
0 commit comments