2017 © Pedro Peláez
 

symfony-bundle fos-rest-extra-bundle

Extra feature for the FOSRestBundle

image

m6web/fos-rest-extra-bundle

Extra feature for the FOSRestBundle

  • Monday, April 10, 2017
  • by M6Web
  • Repository
  • 25 Watchers
  • 0 Stars
  • 70,144 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 8 Versions
  • 5 % Grown

The README.md

fos-rest-extra-bundle

Provide extra feature for the FOSRestBundle., (*1)

Dependency

FOSRestExtraBundle requires FOSRestBundle., (*2)

Installation

Add this line in your composer.json:, (*3)

{
    "require": {
        "m6web/fos-rest-extra-bundle": "~1.0"
    }
}

Update your vendors:, (*4)

$ composer update m6web/fos-rest-extra-bundle

Add to your AppKernel.php:, (*5)

new FOS\RestBundle\FOSRestBundle(),
new M6Web\Bundle\FOSRestExtraBundle\M6WebFOSRestExtraBundle(),

Then modify the FOSRestBundle configuration of your application to add :, (*6)

fost_rest:
    param_fetcher_listener: true

Configuration

m6_web_fos_rest_extra:
    param_fetcher:

        # Define if extra parameters are allowed. The behavior defined here is the default one and can
        # be overrided by a "RestrictExtraParam" annotation on the current action.
        # Optionnal, true by default
        allow_extra: true

        # Define if all parameters are strict. If true, all given parameters have to match defined
        # format for each on of them.
        # Optionnal, false by default
        strict: false

        # HTTP status code of throwed exception on query with invalid parameters
        # Optionnal, 400 by default
        error_status_code: 400

Usage

  • RestrictExtraParam(true/false) Annotation : to allow (false) or forbid (true) unknown parameters, true by default.

use FOS\RestBundle\Controller\Annotations\QueryParam; use M6Web\Bundle\FOSRestExtraBundle\Annotation\RestrictExtraParam; /** * TestController */ class TestController { /** * Restricted controller : only "param1" is permitted * * @return void * * @RestrictExtraParam(true) * * @QueryParam(name="param1", requirements="\d+", nullable=true, description="My Param 1") */ public function getRestrictedAction() { } /** * Unrestricted controller : "param1" and unknown parameters are permitted * except if bundle configuration doesn't allow it * * @QueryParam(name="param1", requirements="\d+", nullable=true, description="My Param 1") * * @return void */ public function getNonRestrictedAction() { } }

Launch Tests

$ bin/atoum

The Versions

10/04 2017

dev-master

9999999-dev

Extra feature for the FOSRestBundle

  Sources   Download

The Requires

 

The Development Requires

by Fabien de Saint pern

10/04 2017
27/02 2017
12/02 2016

v2.1.0

2.1.0.0

Extra feature for the FOSRestBundle

  Sources   Download

The Requires

 

The Development Requires

by Fabien de Saint pern

25/11 2015

v2.0.0

2.0.0.0

Extra feature for the FOSRestBundle

  Sources   Download

The Requires

 

The Development Requires

by Fabien de Saint pern

23/11 2015

v1.1.0

1.1.0.0

Extra feature for the FOSRestBundle

  Sources   Download

The Requires

 

The Development Requires

by Fabien de Saint pern

19/06 2015

v1.0.1

1.0.1.0

Extra feature for the FOSRestBundle

  Sources   Download

The Requires

 

The Development Requires

by Fabien de Saint pern

18/06 2015

v1.0.0

1.0.0.0

Extra feature for the FOSRestBundle

  Sources   Download

The Requires

 

The Development Requires

by Fabien de Saint pern