2017 © Pedro Peláez
 

yii2-extension yii2-httpfull

Extension conversion of 'Httpful' to yii2 extension

image

segpacto/yii2-httpfull

Extension conversion of 'Httpful' to yii2 extension

  • Monday, August 22, 2016
  • by segpacto
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9,475 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

HttpFull

Extension conversion of 'Httpful' to yii2 extension, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Since it is not published on packages.org needs to be installed manually using composer add to your composer.json, (*3)

"repositories":[
    {
        "type": "git",
        "url": "https://path.to/your/repo"
    }
]

since the file is local the 'url' should be "url" : "file:///path_to_your_file"

Either run, (*4)

php composer.phar require --prefer-dist segpacto/yii2-httpfull "*"

or add, (*5)

"segpacto/yii2-httpfull": "*"

to the require section of your composer.json file., (*6)

Usage

Once the extension is installed, simply use it in your code by :, (*7)

// Make a request to the GitHub API with a custom
// header of "X-Trvial-Header: Just as a demo".
$url = "https://api.github.com/users/nategood";
$response = \HttpFull\Request::get($url)
    ->expectsJson()
    ->withXTrivialHeader('Just as a demo')
    ->send();

echo "{$response->body->name} joined GitHub on " .
                        date('M jS', strtotime($response->body->created_at)) ."\n";

Ex 1: Send off a GET request. Get automatically parsed JSON response. The library notices the JSON Content-Type in the response and automatically parses the response into a native PHP object., (*8)

$uri = "https://www.googleapis.com/freebase/v1/mqlread?query=%7B%22type%22:%22/music/artist%22%2C%22name%22:%22The%20Dead%20Weather%22%2C%22album%22:%5B%5D%7D";
$response = \HttpFull\Request::get($uri)->send();

echo 'The Dead Weather has ' . count($response->body->result->album) . " albums.\n";

Ex 2:, (*9)

$uri = 'https://example.net/person.xml';
$response = \HttpFull\Request::get($uri)
    ->expectsXml()
    ->send();

echo "Name: $response->body->name";

Note : This is based on the package shared by nategood. This is only a conversion to use as Yii2 extension. For further explanation and documentation of the package go directly their documentation., (*10)

The Versions

22/08 2016

dev-master

9999999-dev

Extension conversion of 'Httpful' to yii2 extension

  Sources   Download

MIT

The Requires

 

by Ivan Martinez

extension yii2 curl httpfull

22/08 2016

dev-develop

dev-develop

Extension conversion of 'Httpful' to yii2 extension

  Sources   Download

MIT

The Requires

 

by Ivan Martinez

extension yii2 curl httpfull