https://github.com/vzool/url
A Simple RESTful HTTP Client Library using `file_get_contents` only
https://github.com/vzool/url
http-client restful-client
Last synced: about 1 year ago
JSON representation
A Simple RESTful HTTP Client Library using `file_get_contents` only
- Host: GitHub
- URL: https://github.com/vzool/url
- Owner: vzool
- Created: 2018-09-06T10:38:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-09T06:54:50.000Z (almost 8 years ago)
- Last Synced: 2025-05-17T20:12:08.103Z (about 1 year ago)
- Topics: http-client, restful-client
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## A Simple RESTful HTTP Client Library using `file_get_contents` only
[](https://packagist.org/packages/vzool/URL)
[](https://packagist.org/packages/vzool/URL)
[](https://scrutinizer-ci.com/g/vzool/URL/badges/quality-score.png?b=master)
[](https://travis-ci.org/vzool/URL)
### Install
```shell
composer require vzool/url
```
### Usage
```php
require_once __DIR__.'/vendor/autoload.php';
use vzool\URL\URL;
$http = new URL('https://jsonplaceholder.typicode.com');
// to GET
$result = $http->GET('/posts/1');
// to POST
$result = $http->POST('/posts', [
"title" => "Agreement",
"body" => "Ha ha ha",
"author" => "Aziz",
]);
// to PUT
$result = $http->PUT('/posts/1', [
"title" => "Agreement #2",
]);
// to DELETE
$result = $http->DELETE('/posts/1');
// or
$result = $http->delete('/posts/1');
// to get result
print_r($result->content()); // returns stdClass objects :)
print_r($result->toArray()); // returns array
print_r($result->toJson()); // returns raw response, I'm a JSON Patriot ;)
```