PHPackages                             wobblecode/rest-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. [HTTP &amp; Networking](/categories/http)
4. /
5. wobblecode/rest-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

wobblecode/rest-bundle
======================

A bundle that creates REST Apis based on your current controllers actions

v1.1.0(5y ago)312.0k↓42.9%1[3 issues](https://github.com/wobblecode/WobbleCodeRestBundle/issues)MITPHPPHP ~7.1CI failing

Since Jun 7Pushed 5y ago2 watchersCompare

[ Source](https://github.com/wobblecode/WobbleCodeRestBundle)[ Packagist](https://packagist.org/packages/wobblecode/rest-bundle)[ Docs](https://github.com/wobblecode/WobbleCodeRestBundle)[ RSS](/packages/wobblecode-rest-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (19)Versions (16)Used By (0)

WobbleCodeRestBundle
====================

[](#wobblecoderestbundle)

Quick RESTFul Apis For Symofny 3 &amp; 4
----------------------------------------

[](#quick-restful-apis-for-symofny-3--4)

A bundle that creates RESTful Apis in seconds, based on your current controllers actions just using annotations. This is very helpful if you need access to a basic RESTful API under the same domain or page.

A practical Case: if you're using Backbone, you can progressive enhance the functionality supporting common CRUD and One simple page CRUD enabling a quick RESTFul API…

These are the main features:

- Works with your current controllers
- Works with your current Symfony forms
- Intercepts current redirects
- Version api support
- Api based on content negotiation
- Integrated with JMSSerializerBundle
- Integrate with KnpPaginatorBundle to obtain metadata

[![Latest Stable Version](https://camo.githubusercontent.com/77046faffa6dee4427686661ac26e76669f221f989cedcc516118637ee162c50/68747470733a2f2f706f7365722e707567782e6f72672f776f62626c65636f64652f726573742d62756e646c652f762f737461626c652e737667)](https://packagist.org/packages/wobblecode/rest-bundle)[![Total Downloads](https://camo.githubusercontent.com/4e78b72ff02912c2dbff8875bfbd8d5eb3698484a11686439594e44abe37d524/68747470733a2f2f706f7365722e707567782e6f72672f776f62626c65636f64652f726573742d62756e646c652f646f776e6c6f6164732e737667)](https://packagist.org/packages/wobblecode/rest-bundle)[![Travis](https://camo.githubusercontent.com/50b9b95687b3984f4eb2a74d3c4c7245ee8744230f6070fbaec4d12e64439246/68747470733a2f2f7472617669732d63692e6f72672f776f62626c65636f64652f576f62626c65436f64655265737442756e646c652e7376673f6272616e63683d6665617475726525324673796d666f6e79342d737570706f7274)](https://travis-ci.org/wobblecode/WobbleCodeRestBundle/builds)[![License](https://camo.githubusercontent.com/bde4948b72511a60a07d69f17d5226d21f8c5f2ae193ca3231298bd38e3e17e6/68747470733a2f2f706f7365722e707567782e6f72672f776f62626c65636f64652f726573742d62756e646c652f6c6963656e73652e737667)](https://packagist.org/packages/wobblecode/rest-bundle)[![SensioLabsInsight](https://camo.githubusercontent.com/1981c95a6c6c1ebf48b82eced3813b671b124769e2a52c82ad54c62ff3e0f54d/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f32663465313633352d626630362d346638342d393765382d6537393233613431323734622e737667)](https://insight.sensiolabs.com/projects/2f4e1635-bf06-4f84-97e8-e7923a41274b)

### Quick Example

[](#quick-example)

This is the most basic example of use. Just adding the Rest annotation, the api will be available using content negotiation. So if you request JSON, it will return a JSON format schema, If html is requested it will fallback in @Template so the related view will be rendered.

It will use JSMSerializer if it's possible in the model as well.

```
use WobbleCode\RestBundle\Configuration\Rest;

/**
 * @Route("/")
 * @Template()
 * @Rest()
 */
public function indexAction()
{
    ...

    return array(
        'entities' => $entity
    );
}

```

Example using [httpie](https://github.com/jakubroztocil/httpie)(replace your URL if needed)

```
http http://localhost:8000 --json

HTTP/1.1 200 OK
Cache-Control: max-age=0, must-revalidate, no-cache, no-store, public, s-maxage=0
Connection: close
Content-Type: application/json
Host: localhost:8000
X-Debug-Token: 243d5e
X-Debug-Token-Link: /_profiler/243d5e
X-Powered-By: PHP/5.5.7

{
    "entities": [...],
    "metadata": {
        "count": 10,
        "items_per_page": 10,
        "page_number": 1,
        "total_count": 244
    }
}

```

Setup
-----

[](#setup)

### Add to composer

[](#add-to-composer)

```
"wobblecode/rest-bundle": "dev-master",

```

### Enable bundle in Kernel

[](#enable-bundle-in-kernel)

```
new WobbleCode\RestBundle\WobbleCodeRestBundle()

```

Options
-------

[](#options)

**All examples shows the default values.**

### output

[](#output)

List of default objects to serialize from the returned array.

```
/**
 * @Rest(output={"entity", "entities", "meta"})
 */
public function indexAction()
{
    ...

    return array(
        'user'   => $user,
        'post'   => $post,
        'entity' => $entity
    );
}

```

Only `entity` value will be serialized and returned.

### serializeGroups

[](#serializegroups)

List of groups to use with the serializer ( see JMSSerializerBundle groups ). By default will serialize all groups if not defined

```
/**
 * @Rest(serializeGroups={"api", "ui-admin"})
 */

```

### acceptedContent

[](#acceptedcontent)

List of accepted headers that enables REST

```
/**
 * @Rest(acceptedContent={"application/json"})
 */

```

You will have to send `Accept: application/json` in order to enable the REST api functionality. If there is no match, it will fallback to the controller view.

### defaultAccept

[](#defaultaccept)

If Accept header is missing you can set a default value with defaultAccept

```
/**
 * @Rest(defaultAccept="application/json")
 */

```

If the Accept header is missing the default value is `text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8`

### payloadMapping

[](#payloadmapping)

Defines if the payload is assigned to a POST value. This is useful because forms are usually expecting to be received under a POST variable with the name of the form Eg: `$_POST['my_form_name']`

```
/**
 * @Rest(payloadMapping="form")
 */

```

### statusCodeParam

[](#statuscodeparam)

Parameter used to override status code response.

```
/**
 * @Route("/")
 * @Template()
 * @Rest(statusCodeParam="status_code")
 */
public function indexAction()
{
    ...

    return array(
        'status_code' => '403'
    );
}

```

### versionRequired

[](#versionrequired)

Force to send version in Accept header if true

```
/**
 * @Rest(versionRequired=false)
 */

```

### defaultVersion

[](#defaultversion)

Define the default version of the api, false as default for no versioning

### interceptRedirects

[](#interceptredirects)

Intercept 3xx redirects and responds with flash messages

### processForms

[](#processforms)

Process forms errors

### defaultFormParam

[](#defaultformparam)

Process params with name form as principal Form for validation

### Configuration

[](#configuration)

You can set serialize null property on bundle configuration.

```
wobble_code_rest:
    serialize_null: false
```

License
-------

[](#license)

Copyright (c) 2016 Luis Hdez

Released under MIT LICENSE, more info at LICENSE-MIT file.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 90.6% 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 ~199 days

Recently: every ~386 days

Total

13

Last Release

1967d ago

Major Versions

v0.5.2 → v1.0.02018-02-09

PHP version history (3 changes)v0.1.0PHP &gt;=5.3.2

v0.4.2PHP &gt;=5.4

v1.0.0PHP ~7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/4db931a10eeb8ca054434d2c94b2f4a3ac3ddacad73fdfa1622b8002e960e3ef?d=identicon)[luishdez](/maintainers/luishdez)

---

Top Contributors

[![luishdez](https://avatars.githubusercontent.com/u/38347?v=4)](https://github.com/luishdez "luishdez (126 commits)")[![markitosgv](https://avatars.githubusercontent.com/u/1706470?v=4)](https://github.com/markitosgv "markitosgv (13 commits)")

---

Tags

phprestrestfulsymfonyapisymfonyrestrestfulcontent negotiation

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[tbbc/rest-util-bundle

Bundle for integrating tbbc/rest-util lib in a Symfony application.

30205.4k1](/packages/tbbc-rest-util-bundle)[cypresslab/patch-manager

A library to manage patch requests

16117.4k](/packages/cypresslab-patch-manager)

PHPackages © 2026

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