Package Data | |
---|---|
Maintainer Username: | nnjeim |
Maintainer Contact: | nnjeim@nnjeim.net (Najm Njeim) |
Package Create Date: | 2021-09-13 |
Package Last Update: | 2021-10-12 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:19:00 |
Package Statistics | |
---|---|
Total Downloads: | 38 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
A Laravel wrapper for the Guzzle client http library. It provides a fluent syntax to make http requests.
You can install the package via composer:
composer require nnjeim/fetch
php artisan vendor:publish --provider="Nnjeim\Fetch\FetchServiceProvider"
use Nnjeim\Fetch\Fetch;
$countries = Fetch::setBaseUri('https://someapi.com')->get('countries');
use Nnjeim\Fetch\FetchHelper;
private $fetch;
public function __construct(FetchHelper $fetch) {
$this->fetch = $fetch;
}
.
.
.
return $this->fetch
->setBaseUri('https://someapi.com')
->get('countries');
Set the http headers
@return $this setHeaders(array $headers)
Sets the base uri for the composition of the http request url.
@return $this setBaseUri(string 'http://someapi.com/')
Sets the http request url.
@return $this setUrl(string $url)
Sets the http request method.
@return $this setMethod(string $method)
Sets the request body format. The required format are 'query' | 'form_params' | 'multipart'.
@return $this setBodyFormat(string $format)
Sets the type of the request to async.
@return $this setAsync()
Sets the body format to query.
@return array get(?string $url = null, ?array $data = null)
Sets the body format to form-params.
@return array post(?string $url = null, ?array $data = null)
Sets the body format to form-params.
@return array put(?string $url = null, ?array $data = null)
Sets the body format to query.
@return array delete(?string $url = null, ?array $data = null)
Sets the body format to multipart.
@return array upload(?string $url = null, ?array $data = null)
@return array
[
'response' => ...,
'status' => ...,
];
composer test
Please see CHANGELOG for more information what has changed recently.