2017 © Pedro Peláez
 

library hal

image

mhndev/hal

  • Monday, November 20, 2017
  • by majidphpdeveloper
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version Total Downloads Latest Unstable Version License composer.lock, (*1)

Php Hal Object

generating php hal object from array data, (*2)

this package currently just supports json and not xml, (*3)

Sample usage:


$post = [ 'title' => 'sample post title', 'text' => 'post body goes here ...', ]; $user = [ 'username' => 'mhndev', 'mobile' => '09124917706', 'email' => 'majid8911303@gmail.com' ]; $comments = [ [ 'text' => 'Hi', 'uid' => 12 ], [ 'text' => 'OK', 'uid' => 14 ], [ 'text' => 'NOK', 'uid' => 10 ] ]; $tags = [ 'tag1', 'tag2', 'tag3' ]; $profile = [ 'avatar' => 'http://google.com/inja.jpeg', 'name' => 'majid', 'username' => 'mhndev', 'bio' => 'user biography goes here ...' ]; $self_link = new \mhndev\hal\Link('self', 'http://google.com'); $next_link = new \mhndev\hal\Link('next', 'http://google.com'); $postResource = new \mhndev\hal\Resource($post); $profileResource = new \mhndev\hal\Resource($profile); $profileResource->addLink($self_link); $userResource = new \mhndev\hal\Resource($user); $userResource->addEmbeddedResource($profileResource, 'profile'); $tagsResource = new \mhndev\hal\Resource($tags); $request = \Slim\Http\Request::createFromGlobals([]); $commentsResource = new \mhndev\hal\Paginated($comments, 5 , 10, $request); $postResource->addEmbeddedResource($userResource, 'user'); $postResource->addEmbeddedResource($tagsResource, 'tags'); $postResource->addEmbeddedResource($commentsResource, 'comments'); $postResource->addLink($next_link); $postResource->addLink($self_link); header('Content-Type: application/json'); $presenter = new \mhndev\hal\Presenter($postResource); var_dump((new \mhndev\hal\Presenter($postResource))->asArray());die(); echo $presenter->asJson();

The Versions

20/11 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

20/11 2017

0.6.0

0.6.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

20/11 2017

0.5.0

0.5.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

20/11 2017

0.3.0

0.3.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

20/11 2017

0.4.0

0.4.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

15/11 2017

0.2.0

0.2.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

15/11 2017

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

14/11 2017

0.0.3

0.0.3.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

14/11 2017

0.0.2

0.0.2.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response

12/11 2017

0.0.1

0.0.1.0

  Sources   Download

MIT

The Requires

 

The Development Requires

hal object hal http response