2017 © Pedro Peláez
 

symfony-bundle rest-bundle

Provides a REST-like API for the Doctrine entities in a Symfony application.

image

outlandish/rest-bundle

Provides a REST-like API for the Doctrine entities in a Symfony application.

  • Friday, February 21, 2014
  • by tamlyn
  • Repository
  • 5 Watchers
  • 2 Stars
  • 872 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 8 % Grown

The README.md

REST API in a Box

The OutlandishRestBundle provides a REST-like API for the Doctrine entities in a Symfony application. It is highly opinionated and requires no configuration which makes it an excellent choice for rapid prototyping with JavaScript frameworks such as Angular, Ember and Backbone., (*1)

Features:, (*2)

  • automatically generates routes
  • uses JMSSerializer bundle
  • uses Symfony validator component
  • serializes errors and exceptions
  • supports Doctrine associations
  • uses JSON only
  • pagination
  • simple data queries using FIQL
  • authentication can be added using the security component

For example if you have Acme\FooBundle\Entity\Bar then you can do the following:, (*3)

GET /api/bar
// returns [{"id":1, ...}, {"id":2, ...}]

GET /api/bar/1
// returns {"id":1, ...}

POST /api/bar
{"foo":"baz", ...}
// returns {"id":3, "foo":"baz", ...}

PUT /api/bar/2
{"foo":"buzz", ...}
// returns {"id":2, "foo":"buzz", ...}

DELETE /api/bar/3
// returns nothing

GET /api/bar?id=gt=2&foo=baz
// returns [{"id":3, ...}]

GET /api/bar?per_page=2&offset=1
// returns [{"id":2, ...}, {"id":3, ...}]

GET /api/bar/0
// returns [{"message":"Entity not found"}]

POST and PUT requests expect JSON encoded entity data in the request body., (*4)

On error, a status code of 400, 404 or 500 is returned and the response body is an array of messages., (*5)

Installation

1. Add to composer.json

"require": {
    "outlandish/rest-bundle": "dev-master",
},

2. Run composer update

3. Add to AppKernel.php

public function registerBundles()
{
    $bundles = array(
        //...
        new Outlandish\RestBundle\OutlandishRestBundle(),
    );

    return $bundles;
}

5. Edit app/config/routing.yml

#...

outlandish_rest:
    resource: .
    type: outlandish_rest
    prefix: /api

The Versions

21/02 2014

dev-master

9999999-dev

Provides a REST-like API for the Doctrine entities in a Symfony application.

  Sources   Download

The Requires

 

rest doctrine

21/02 2014

v1.0

1.0.0.0

Provides a REST-like API for the Doctrine entities in a Symfony application.

  Sources   Download

The Requires

 

rest doctrine