Download the PHP package sfn/httpclient without Composer
On this page you can find all versions of the php package sfn/httpclient. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package httpclient
Sfn HttpClient
Just a simple and little PSR7 client. It is still a work-in-progress but, more or less, it works.
Table of Contents
- Requirements
- Installation
- Zend Diactoros support
- Guzzle support
- Slim support
- Usage
- Create a client instance
- Send a request
- Methods for REST API
- Base URI
- To-do
- License
Requirements
- PHP 7.0 or higher
php-curlorallow_url_fopenset to true- A PSR7 implementation.
Sfn\HttpClient needs a PSR-7 implementation. It supports
Zend Diactoros,
Guzzle and
Slim at the moment.
Of course you can write your own HTTP Factory implementation for any PSR-7 implementation, look here for PSR-17 Http Factory interfaces.
Installation
Install using Composer.
Zend Diactoros support
Guzzle support
Slim support
Usage
Create a client instance
With the ClientFactory::make() method you can create the correct instance
of the client. If it finds curl installed, it creates a client with a curl
backend, otherwise it create a client who send request via php's
file_get_contents.
ClientFactory::make() accepts an associative array with the client
configuration. You must specify at least your PSR-17 HTTP Factory implementation.
Here you can find the complete
list of parameters in you can set in the configuration array.
Send a request
First of all, you must create a request with your preferred
Psr\Http\Message\RequestInterface implementation. Then you simply call the
send() method of the client.
Helper methods for REST API
There are get(), post(), put(), delete() and patch() helper methods.
You can pass a second parameter, with an array of options.
Here you can find a complete list of request
parameters.
Base URI
You can also specify a base uri in the client configuration.
To-Do
- Cookies support
- SSL authentication
- Examples
- Better documentation
License
MIT License