2017 © Pedro Peláez
 

library hal-guzzle-response

Adds Hal resources to Guzzle Responses

image

rmiller/hal-guzzle-response

Adds Hal resources to Guzzle Responses

  • Thursday, September 10, 2015
  • by mr_r_miller
  • Repository
  • 2 Watchers
  • 4 Stars
  • 755 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

HalGuzzleResponse

Scrutinizer Code Quality Build Status, (*1)

Guzzle event subscriber to decorate responses to provide Hal resources., (*2)

If you register the listener it will decorate the responses from Guzzle giving them a hal method. This will return a Nocarrier\Hal resource created from the response body., (*3)

Installation

Require the extension:, (*4)

$ composer require rmiller/hal-guzzle-response:~0.1

Usage

Attach the listener:, (*5)

$client = new \GuzzleHttp\Client();
$emitter = $client->getEmitter();
$subscriber = new \RMiller\HalGuzzleResponse\GuzzleSubscriber();
$emitter->attach($subscriber);

Get the Hal resource from the response:, (*6)

$response = $client->get($url);
$hal = $response->hal(); //\Nocarrier\Hal

Note: an attempt will be made to convert the response body from JSON and XML to a Hal resource. If neither is successful a \RuntimeException will be thrown. This happens when hal is called, so it is safe to wrap other responses and not call hal., (*7)

The Versions