maesbox / api-bundle
bundle for api common functions
1.0.3
2017-01-16 11:51 UTC
Requires
- php: >=5.3.9
- doctrine/doctrine-bundle: ~1.4
- doctrine/orm: >=2.4
- friendsofsymfony/rest-bundle: >=1.0
- jms/serializer-bundle: >=1.0
- maesbox/common-bundle: >=1.0.2
- nelmio/api-doc-bundle: >=2.0
- nelmio/cors-bundle: >=1.0
- symfony/symfony: >=2.8
This package is auto-updated.
Last update: 2024-12-13 11:16:48 UTC
README
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