2017 © Pedro Peláez
 

library hal-client

HalClient

image

ekino/hal-client

HalClient

  • Friday, October 17, 2014
  • by ekino
  • Repository
  • 21 Watchers
  • 31 Stars
  • 9,310 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 14 Forks
  • 7 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

HalClient

Build Status, (*1)

HalClient is a lightweight library to consume HAL resources., (*2)

Installation using Composer

Add the dependency:, (*3)

php composer.phar require ekino/hal-client

If asked for a version, type in 'dev-master' (unless you want another version):, (*4)

Please provide a version constraint for the ekino/hal-client requirement: dev-master

Limitations

There is no support for POST/PUT/PATCH/DELETE methods., (*5)

Usage


<?php // create a HttpClient to perform http request $client = new FileGetContentsHttpClient('http://propilex.herokuapp.com', array( 'Authorization' => 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==' )); // create an entry point to retrieve the data $entryPoint = new EntryPoint('/', $client); $resource = $entryPoint->get(); // return the main resource // retrieve a Resource object, which acts as a Pager $pager = $resource->get('p:documents'); $pager->get('page'); $collection = $pager->get('documents'); // return a ResourceCollection // a ResourceCollection implements the \Iterator and \Countable interface foreach ($collection as $document) { // the document is a resource object $document->get('title'); }

Integrate JMS/Deserializer

The library support deserialization of Resource object into native PHP object., (*6)


$serializer = Ekino\HalClient\Deserialization\Builder::build(); $object = $serializer->deserialize($resource, 'Acme\Article', 'hal');

The Versions

17/10 2014
17/10 2014