overburn / http-request
CURL wrapper for Laravel
1.0.0
2016-05-05 10:01 UTC
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2024-09-28 19:52:37 UTC
README
Installation
Update your composer.json
file to include this package as a dependency
"overburn/http-request": "~1.0"
Register the HttpRequest service provider by adding it to the providers array in the config/app.php
file.
Overburn\HttpRequest\HttpRequestServiceProvider::class
Alias the HttpRequest facade by adding it to the aliases array in the config/app.php
file.
'aliases' => [ 'HttpRequest' => Overburn\HttpRequest\Facades\HttpRequest::class ]
Usage
HttpRequest::request
Sends a request , and returns an array of the following form:
[ "response" => "response body given by the server", "info" => "the results of curl_getinfo() on the current request" ]
Example:
$options = [ "method" => "get", "url" => "http://www.example.com" ]; HttpRequest::request($options);
The options is an array
$options = [ "method" => "get", //required - get, post, put, patch, delete "url" => "http://www.example.com", //required "params" => ["parameter"=>"value", "another" => "newvalue"], // url parameters for the request (optional) "data" => ["postdata[]"=>"avalue", "postdata[]"=>"anothervalue"], // data for post/put/patch/delete requests (optional, not available on "get") "files" => ["file" => "./example.pdf"], //an array of files (optional, not available on "get") ]