Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mawuva/http-request-wrapper
A simple and lighter wrapper around Guzzle HTTP client
https://github.com/mawuva/http-request-wrapper
Last synced: 7 days ago
JSON representation
A simple and lighter wrapper around Guzzle HTTP client
- Host: GitHub
- URL: https://github.com/mawuva/http-request-wrapper
- Owner: mawuva
- License: mit
- Created: 2021-06-18T21:36:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-06-19T09:55:20.000Z (over 3 years ago)
- Last Synced: 2024-09-22T17:08:41.956Z (about 2 months ago)
- Language: PHP
- Homepage: https://packagist.org/packages/mawuekom/http-request-wrapper
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# HTTP Request Wrapper
[![License](https://poser.pugx.org/mawuekom/http-request-wrapper/license)](https://packagist.org/packages/mawuekom/http-request-wrapper)
This package provide a simple and lighter wrapper around [Guzzle HTTP client](https://docs.guzzlephp.org/en/stable/index.html)
## Installation
You can install the package via composer:
```bash
composer require mawuekom/http-request-wrapper
```## Usage
```php
// Simple usageuse Mawuekom\HttpRequestWrapper\HttpRequest;
$request = new HttpRequest('http://httpbin.org');
$response = $request ->send('GET', 'get');echo $response ->getBody();
```### Using custom methods
```php
// Simple usageuse Mawuekom\HttpRequestWrapper\HttpRequest;
$request = new HttpRequest('http://httpbin.org');
$response = $request ->get('get');// You can also override default base URI
$response = $request ->get('http://httpbin.org/get');$request ->post('http://httpbin.org/post');
$request ->put('http://httpbin.org/put');
$request ->patch('http://httpbin.org/patch');
$request ->delete('http://httpbin.org/delete');
```You can also use helper
```php
use Mawuekom\HttpRequestWrapper\Helpers\HttpRequestHelper;class Test
{
use HttpRequestHelper;private $baseUri = 'http://httpbin.org/';
public function data()
{
$res = $this ->makeRequest('GET', 'get');return $res ->getBody();
}public function getData()
{
$res = $this ->get('get');return $res ->getBody();
}
}
```### Testing
```bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.