Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.
/ php-hal-client Public archive

HalClient is a lightweight PHP library to consume HAL resources.

License

Notifications You must be signed in to change notification settings

ekino/php-hal-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HalClient

Build Status

HalClient is a lightweight library to consume HAL resources.

Installation using Composer

Add the dependency:

php composer.phar require ekino/hal-client

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

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

Limitations

There is no support for POST/PUT/PATCH/DELETE methods.

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.

$serializer = Ekino\HalClient\Deserialization\Builder::build();

$object = $serializer->deserialize($resource, 'Acme\Article', 'hal');

About

HalClient is a lightweight PHP library to consume HAL resources.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages