vzool/url

A Simple RESTful HTTP Client Library using file_get_contents only

v0.10 2018-09-09 06:28 UTC

This package is auto-updated.

Last update: 2024-11-09 20:28:32 UTC


README

Latest Stable Version License Scrutinizer Code Quality Build Status

Install

composer require vzool/url

Usage

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 ;)