PHPackages                             fsc/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. [API Development](/categories/api)
4. /
5. fsc/rest-bundle

ActiveLibrary[API Development](/categories/api)

fsc/rest-bundle
===============

7255[1 issues](https://github.com/TheFootballSocialClub/FSCRestBundle/issues)[1 PRs](https://github.com/TheFootballSocialClub/FSCRestBundle/pulls)PHP

Since Oct 11Pushed 13y ago4 watchersCompare

[ Source](https://github.com/TheFootballSocialClub/FSCRestBundle)[ Packagist](https://packagist.org/packages/fsc/rest-bundle)[ RSS](/packages/fsc-rest-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

FSCRestBundle
=============

[](#fscrestbundle)

[![Build Status](https://camo.githubusercontent.com/e7b3ab1fe2a27138fcb933e2195c6dac78b44a30e4bdf2a135d0fade03dc2f80/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f546865466f6f7462616c6c536f6369616c436c75622f4653435265737442756e646c652e706e67)](http://travis-ci.org/TheFootballSocialClub/FSCRestBundle)

This bundle will generate a REST HATEOAS api based on the configuration you'll do. ATM it can only generate a read only api, backed by doctrine ORM. The representations are optimized for the XML format, but are also usable in JSON.

If you create relations between resources, the bundle will automatically create links between them.

The design obviously took many shortchuts, and is not a reference of OOP design ... but it works. But it's easy to override behavior because you need to the extend the classe that does everything, for each resource...

This bundle was extracted from an app, and need some love to be usable. (ie composer, make tests work etc ...)

LICENSE
-------

[](#license)

MIT: Resources/meta/LICENSE

TODO
----

[](#todo)

- Create a "sanbox" symfony2 app to demonstrate how to fully use the bundle

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

[](#installation)

Edit your composer.json like this:

```
{
    "require": {
        ...
        "jms/serializer-bundle": "dev-xml-attribute-map as 0.9.0",
        "fsc/rest-bundle": "*"
        ...
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/adrienbrault/JMSSerializerBundle"
        }
    ]
}
```

Update your deps: `composer update`.

Add the bundle to your AppKernel:

```
// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new FSC\RestBundle\FSCRestBundle(),
    new JMS\SerializerBundle\JMSSerializerBundle(),
    new FOS\FOSRestBundle(),
    // ...
);
```

Be aware that this bundle relies on a fork of JMSSerializerBundle, because this PR is still not merged: [schmittjoh/JMSSerializerBundle#164](https://github.com/schmittjoh/JMSSerializerBundle/pull/164)

Example
-------

[](#example)

For an example of what the controller returns:

You need to define services, tagged with `fsc_rest.resource`.

```
services:
    fsc.core.spot.resource.spots:
        class: FSC\Core\SpotBundle\REST\SpotsResource
        parent: fsc.rest.resource.abstract_doctrine
        tags:
          - { name: fsc_rest.resource }
```

```
