https://github.com/jaredchu/jcrequest
Another Guzzle wrapper
https://github.com/jaredchu/jcrequest
composer composer-package http-client php php-library php7
Last synced: about 1 year ago
JSON representation
Another Guzzle wrapper
- Host: GitHub
- URL: https://github.com/jaredchu/jcrequest
- Owner: jaredchu
- License: mit
- Created: 2017-05-31T02:48:18.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-30T05:53:04.000Z (about 8 years ago)
- Last Synced: 2025-03-24T15:11:20.494Z (about 1 year ago)
- Topics: composer, composer-package, http-client, php, php-library, php7
- Language: PHP
- Size: 34.2 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JCRequest
Another Guzzle wrapper
[](https://packagist.org/packages/jaredchu/jc-request)
[](https://packagist.org/packages/jaredchu/jc-request)
[](https://travis-ci.org/jaredchu/JCRequest)
[](https://scrutinizer-ci.com/g/jaredchu/JCRequest/)
[](https://codecov.io/gh/jaredchu/JCRequest)
[](https://packagist.org/packages/jaredchu/jc-request)
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjaredchu%2FJCRequest?ref=badge_shield)
## Installation
`$ composer require jaredchu/jc-request`
## Usage
```PHP
use JC\HttpClient\JCRequest;
```
#### GET
```PHP
$response = JCRequest::get($url);
echo $response->status();
echo $response->body();
var_dump($response->json());
```
#### POST
```PHP
$response = JCRequest::post($url, $params, $headers);
echo $response->status();
echo $response->body();
var_dump($response->json());
```
#### RESTful
```PHP
$response = JCRequest::post($url, json_encode($params), $headers);
var_dump($response->json());
```
### Basic Auth
```PHP
$response = JCRequest::get($url, $params, $headers, [
'auth' => [$userName, $passwd]
]);
```
### Request timeout
```PHP
$response = JCRequest::get($url, $params, $headers, [
'connect_timeout' => 2,
'timeout' => 2
]);
```
## Contributing
1. Fork it!
2. Create your feature branch: `$ git checkout -b feature/your-new-feature`
3. Commit your changes: `$ git commit -am 'Add some feature'`
4. Push to the branch: `$ git push origin feature/your-new-feature`
5. Submit a pull request.
## License
[MIT License](https://github.com/jaredchu/JCRequest/blob/master/LICENSE)
[](https://app.fossa.io/projects/git%2Bhttps%3A%2F%2Fgithub.com%2Fjaredchu%2FJCRequest?ref=badge_large)