PHPackages                             kmfk/hateoas-bundle - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kmfk/hateoas-bundle

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kmfk/hateoas-bundle
===================

Symfony2 Bundle to add Hateoas compliant urls to JMS Serializer

0.1.1(12y ago)2621MITPHPPHP &gt;=5.4.0

Since Jan 30Pushed 11y ago1 watchersCompare

[ Source](https://github.com/kmfk/hateoas-bundle)[ Packagist](https://packagist.org/packages/kmfk/hateoas-bundle)[ Docs](https://github.com/kmfk/hateoas-bundle)[ RSS](/packages/kmfk-hateoas-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Hateoas Bundle
==============

[](#hateoas-bundle)

While this works as a simple, drop in bundle for Symfony, you can find a much more full featured library and bundle here:

- [Hateoas](https://github.com/willdurand/Hateoas)
- [BazingaHateoasBundle](https://github.com/willdurand/BazingaHateoasBundle)

\###Overview

The Hateoas Bundle works with JMS Serializer to allow you to easily add Hateoas compliant resource urls to the JSON output of your REST Api.

There are other similar bundles, but they seemed heavy for my needs. This bundle was designed to work seamlessly with [JMS Serializer](https://github.com/schmittjoh/JMSSerializerBundle), with out needing to abstract or obfuscate the serialization of your data.

Currently this bundle only provides Annotations for Resource Linking in your Serialized response.

\###Hateoas Bundle Installation

The best method of installation is through the use of composer.

\#####Add the bundle to Composer

```
"require": {
    "kmfk/hateoas-bundle": "~0.1",
}
```

\#####Update AppKernel.php

Add The Hateoas Bundle to your kernel bootstrap sequence

```
public function registerBundles()
{
	$bundles = array(
    	// ...
    	new Kmfk\Bundle\HateoasBundle\HateoasBundle(),
    );

    return $bundles;
}
```

\####Configure the Bundle

The bundle allows you to configure the Rest API host and an optional Path prefix. Your links will be built using these values. If they are not set, the bundle will default to parsing this from the current request.

```
#app/config.yml

hateoas:
	host:   http://api.example.com/
	prefix: /api/

```

\###Annotations

Once configured, you can use the Annotations provided by this bundle to easily add resource links to your classes and properties.

```
#src/AcmeBundle/Entity/UserEntity.php

use Kmfk/Bundle/HateoasBundle/Annotation/Hateoas;

/**
 * @Hateoas(
 *      name    ="self",
 *      href    ="/user/{id}/"
 *      params  ={"id" = "getId"},
 *      groups  ={"list"},
 *      type    ="absolute"
 *  )
 */
class UserEntity
{
    protected $id;

    public function getId()
    {
        return $this->id;
    }
}
```

\####Output:

```
{
    "_links": {
        "self": {
            "href": "http://api.example.com/api/user/1/"
        }
    }
}
```

\###Annotation Reference

PropertyDescriptionExample`name`The property name inside the 'links' attribute`user``href`The relative (path) url of the resource, including url tokens`/user/{id}/``params`An associative array of token names with their corresponding getter methods`{ "id" = "getId" }``groups`Serializer Groups, Used the same way as JMS Serializer Groups`{ "partial", "full" }``type`'Absolute' or 'Embedded'`absolute`\####Using Params You can have multiple tokens in the `href`. The `params` array should be an associative array with keys matching the tokens in the path. Methods listed should be methods that exist in the annotated class.

\####Groups Specifying `groups` allow you to control the output of the links based on [Exclusion Groups](http://jmsyst.com/libs/serializer/master/reference/annotations#groups)

\####Embedded vs Absolute Links While `absolute` (default value), will allows include the API Host and optional prefix, `embedded` urls live beneath another resource. Setting type to '`embedded` will allow you to have links like:

```
{
    "_links": {
        "self": {
            "href": "http://api.example.com/api/user/1/email/1/"
        }
    }
}
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4488d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/84ad9179e2241e556ef5d5155b3ec773d40562d325d4f9106c01af365a080a8d?d=identicon)[kmfk](/maintainers/kmfk)

---

Top Contributors

[![cryptiklemur](https://avatars.githubusercontent.com/u/896295?v=4)](https://github.com/cryptiklemur "cryptiklemur (1 commits)")[![k-k](https://avatars.githubusercontent.com/u/2430033?v=4)](https://github.com/k-k "k-k (1 commits)")

---

Tags

jsonsymfonybundleHATEOAS

### Embed Badge

![Health badge](/badges/kmfk-hateoas-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kmfk-hateoas-bundle/health.svg)](https://phpackages.com/packages/kmfk-hateoas-bundle)
```

###  Alternatives

[presta/sitemap-bundle

A Symfony bundle that provides tools to build your application sitemap.

3929.4M28](/packages/presta-sitemap-bundle)[symfony-bundles/json-request-bundle

Symfony JsonRequest Bundle

501.6M6](/packages/symfony-bundles-json-request-bundle)[bukashk0zzz/liip-imagine-serialization-bundle

Provides integration between LiipImagineBundle and JMSSerializerBundle.

2517.5k](/packages/bukashk0zzz-liip-imagine-serialization-bundle)[mcfedr/json-form

A couple of helper files for handling json with symfony forms

1387.5k1](/packages/mcfedr-json-form)[eprofos/user-agent-analyzer

A powerful Symfony bundle for user-agent analysis. It provides accurate detection of operating systems (Windows, MacOS, Linux, iOS, Android...), browsers (Chrome, Firefox, Safari...), and device types (Desktop, Mobile, Tablet, TV...). Supports specific version detection and includes advanced handling of special cases like WebViews and compatibility modes. Features comprehensive logging and detailed analysis results.

182.3k](/packages/eprofos-user-agent-analyzer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
