2017 © Pedro Peláez
 

library restclient

REST Client

image

wrossmann/restclient

REST Client

  • Tuesday, February 2, 2016
  • by wrossmann
  • Repository
  • 1 Watchers
  • 0 Stars
  • 31 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

REST Client Wrapper

Provides an implementation-agnostic client and abstracts away the details of interacting with a REST API, translates requests like:, (*1)

  • GET http://example.com/resource/{id}/action to $rest->resource->$id->action()
  • GET http://example.com/resource/{id}/action?param=foo to $rest->resource->$id->action(['param'=>'foo'])
  • POST http://example.com/resource with data param=foo to $rest->resource->$id->action(['param'=>'foo'], 'post')
  • and so on for DELETE and PUT as well.

Resource instantiation is chained and cached for speed and memory efficiency, and requests are executed by the single Guzzle instance in the root REST\Client object., (*2)

Authentication

Easily supports REST endpoints that rely on authentication tokens in the headers via the basicHeaders() function which can be modified to set token values, as well as common required Accept: and Content-Type headers, eg:, (*3)

public function basicHeaders() {
    return [
        'Accept'    => 'application/json',
        'Content-Type'  => 'application/json',
        'X-Auth-Token'  => isset($this->authToken) ? $this->authToken : '';
    ];
}

Note: Currently the client does not have a baked-in way to deal with REST services that require request signing, but you should be able to override Client::guzzle() to accomplish this., (*4)

The Versions

02/02 2016

dev-master

9999999-dev

REST Client

  Sources   Download

The Requires

 

by Wade Rossmann

30/11 2015

1.0.3

1.0.3.0

REST Client

  Sources   Download

The Requires

 

by Wade Rossmann