maesbox/api-bundle

bundle for api common functions

1.0.3 2017-01-16 11:51 UTC

This package is auto-updated.

Last update: 2024-04-13 09:48:43 UTC


README

Latest Stable Version Total Downloads License SensioLabsInsight

this bundle provides base functionnalities for rest api's

Installation

composer

composer require maesbox/apibundle ~1.1

kernel

add these lines to app/AppKernel.php

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
		...
			new FOS\RestBundle\FOSRestBundle(),
			new Nelmio\CorsBundle\NelmioCorsBundle(),
			new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
			new Maesbox\CommonBundle\MaesboxCommonBundle(),
			new Maesbox\ApiBundle\MaesboxApiBundle(),

		...
		);
	}
	...
}

routing

add these lines to app/routing.yml

MaesboxApiBundle:
	resource: "@MaesboxApiBundle/Resources/config/routing.yml"
	prefix:   /api

note: le routing du nelmio/api-doc-bundle est ajouté par défaut

Features

controller

the bundle provides base classe for rest controller please refer to friendofsymfony/rest-bundle documentation for more informations

<?php

use Maesbox\ApiBundle\BaseClass\BaseRestController;

class AppController extends BaseRestController
{

}

exception listener

the bundle provides an exception listener in order to convert exception to json response

add this lines to config.yml

maesbox_api:
	exception_listener: true