PHPackages                             mixerapi/hal-view - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. mixerapi/hal-view

ActiveCakephp-plugin[Templating &amp; Views](/categories/templating)

mixerapi/hal-view
=================

A Hypertext Application Language (HAL+JSON) view for CakePHP.

v2.0.7(3mo ago)042.0k↑43.3%[1 issues](https://github.com/mixerapi/hal-view/issues)1MITPHPPHP ^8.1

Since Aug 10Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/mixerapi/hal-view)[ Packagist](https://packagist.org/packages/mixerapi/hal-view)[ RSS](/packages/mixerapi-hal-view/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (31)Used By (1)

MixerApi HAL View
=================

[](#mixerapi-hal-view)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7cfa85e51f743f7d55ddfb70f008f7215143357999d149ed6ea2e2e8543484b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d697865726170692f68616c2d766965772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mixerapi/hal-view)[![Build](https://github.com/mixerapi/mixerapi-dev/workflows/Build/badge.svg?branch=master)](https://github.com/mixerapi/mixerapi-dev/actions?query=workflow%3ABuild)[![Coverage Status](https://camo.githubusercontent.com/980eb71f87b8f84d118d946d1a90203dbc53bbc8ac87363bc543899b32c0d2a0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d697865726170692f6d697865726170692d6465762f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mixerapi/mixerapi-dev?branch=master)[![MixerApi](https://camo.githubusercontent.com/bca1ea90642661e0908fc7ad1c1cdbd704cda1063a2cb40801fab9d0ccdbd6af/68747470733a2f2f6d697865726170692e636f6d2f6173736574732f696d672f6d697865722d6170692d7265642e737667)](http://mixerapi.com)[![CakePHP](https://camo.githubusercontent.com/21b7bf61684c39eabf40bb424dd733f6f3a4bd11de430f8accc24ba0445b4b9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63616b657068702d253545342e322d7265643f6c6f676f3d63616b65706870)](https://book.cakephp.org/4/en/index.html)[![Minimum PHP Version](https://camo.githubusercontent.com/7f2179949cf3def20f5d08c400d94cf1c6c68c30bdaa05546c78e33eccded56f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d3838393242462e7376673f6c6f676f3d706870)](https://php.net/)

A Hypertext Application Language ([HAL+JSON](http://stateless.co/hal_specification.html)) View for CakePHP. This plugin supports links, pagination, and embedded resources. Once setup any request with `application/hal+json` will be rendered by this plugin.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Setup](#setup)
- [Usage](#usage)
- [Serializing](#serializing)

Installation
------------

[](#installation)

!!! note "" You can skip this step if MixerAPI is installed.

```
composer require mixerapi/hal-view
bin/cake plugin load MixerApi/HalView
```

Alternatively after composer installing you can manually load the plugin in your Application:

```
# src/Application.php
public function bootstrap(): void
{
    // other logic...
    $this->addPlugin('MixerApi/HalView');
}
```

Setup
-----

[](#setup)

Your controllers must be using the `RequestHandler` component. This is typically loaded in your `AppController`.

```
# src/Controller/AppController.php
public function initialize(): void
{
    parent::initialize();
    $this->loadComponent('RequestHandler');
    // other logic...
}
```

Usage
-----

[](#usage)

For `_link.self.href` support you will need to implement `MixerApi\HalView\HalResourceInterface` on entities that you want to expose as HAL resources. This informs the plugin that the Entity should be treated as a HAL resource and provides the mapper with a `_link.self.href` URL:

```
