PHPackages                             alterway/rest-hal-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. alterway/rest-hal-bundle

AbandonedArchivedSymfony-bundle

alterway/rest-hal-bundle
========================

manage HAL Rest API with Symfony2 http://stateless.co/hal\_specification.html

v0.0.2(12y ago)145568[2 PRs](https://github.com/alterway/RestHalBundle/pulls)MITPHPPHP ~5.3

Since Nov 7Pushed 12y ago1 watchersCompare

[ Source](https://github.com/alterway/RestHalBundle)[ Packagist](https://packagist.org/packages/alterway/rest-hal-bundle)[ RSS](/packages/alterway-rest-hal-bundle/feed)WikiDiscussions master Synced 3d ago

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

\# RestHalBundle

Bundle to manage [Hal API](http://stateless.co/hal_specification.html) with Symfony2.

\## Installation

Edit your `composer.json`:

```
"require": {
    "alterway/rest-hal-bundle" : "master"
}
```

And run Composer:

```
php composer.phar update alterway/rest-hal-bundle

```

Add the following line at the end of your `autoload.php`:

```
Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
```

Enable your bundle in your `AppKernel.php`:

```
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Alterway\Bundle\RestHalBundle\AwRestHalBundle(),
    );
}
```

Usage
-----

[](#usage)

### Resource

[](#resource)

A resource is a PHP class who represents informations about elements of your applications.

For example:

```
// src/Alterway/DemoBundle/ApiResource/UserResource.php

namespace Alterway\DemoBundle\ApiResource;

use Alterway\Bundle\RestHalBundle\ApiResource\Resource;

class UserResource extends Resource
{
    public function __construct(RouterInterface $router, User $user)
    {
        parent::__construct($router);
        $this->user = $user;
    }

    protected function prepare()
    {
        $this->addLink('next', '/users?page=2');
        $this->addLink('search', '/users?id={user_id}');
    }

    protected function generateUri()
    {
        return $this->router->generate('demo.user', array('id' => 1));
    }
}
```

### Controller

[](#controller)

#### With annotations:

[](#with-annotations)

Remember to enable annotations :

```
sensio_framework_extra:
router:  { annotations: true }
request: { converters: true }
view:    { annotations: true }
cache:   { annotations: true }

```

```
// some controller or yours

use Alterway\DemoBundle\ApiResource\UserResource;

/**
 * @Hal(code="200")
 */
public function userWithAnnotateAction(Request $request)
{
    $user = new User;
    return new UserResource($this->get('router'), $user);
}
```

#### Without annotations:

[](#without-annotations)

```
// some controller or yours

use Alterway\Bundle\HalRestBundle\Response\HalResponse;
use Alterway\DemoBundle\ApiResource\UserResource;

public function userWithoutAnnotateAction(Request $request)
{
    $user = new User;
    $resource = new UserResource($this->get('router'), $user);
    return new HalResponse($resource, 200);
}
```

\## Contribute

Install dev dependencies:

```
php composer.phar update

```

Run Behat:

```
./vendor/bin/behat @AwRestHalBundle

```

Copyright
---------

[](#copyright)

Copyright (c) 2013 La Ruche Qui Dit Oui!. See LICENSE for details.

Contributors
------------

[](#contributors)

- Jean-François Lépine (Halleck45)
- Benoît Merlet (trompette)
- Antoine Lévêque (gh0stonio)

Sponsors
--------

[](#sponsors)

- [Alter Way](http://www.alterway.fr)
- [La Ruche Qui Dit Oui !](http://www.laruchequiditoui.fr)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~50 days

Total

2

Last Release

4522d ago

PHP version history (2 changes)v0.0.1PHP &gt;=5.3.3

v0.0.2PHP ~5.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/919c0dd2d4755f6195d031c004340879606dfe43946fef8758edf5161271728e?d=identicon)[herveleclerc](/maintainers/herveleclerc)

---

Top Contributors

[![gh0stonio](https://avatars.githubusercontent.com/u/1764557?v=4)](https://github.com/gh0stonio "gh0stonio (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alterway-rest-hal-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/alterway-rest-hal-bundle/health.svg)](https://phpackages.com/packages/alterway-rest-hal-bundle)
```

###  Alternatives

[ed/blog-bundle

Symfony EDBlogBundle

348.4k](/packages/ed-blog-bundle)[ecentria/ecentria-rest-bundle

Goal of this bundle is to simplify process of creating APIs with Symfony. We use already well-coded libraries, combine them together to simplify process and not to re-invent the wheel. We've chose REST and HATEOS to have unified standards of API requests and responses.

142.4k](/packages/ecentria-ecentria-rest-bundle)[symfonyid/admin-bundle

Provide Admin Generator with KISS Principle

141.6k](/packages/symfonyid-admin-bundle)

PHPackages © 2026

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