This bundle provides tools to implement an API according to the MediaMonks REST API specifications:
- Converts all responses automatically to the specification
- Accepts application/json, application/x-www-form-urlencoded & multipart/form-data input
- Supports json and xml response
- Supports method overriding
- Supports forcing a "200 OK" status method
- Supports paginated responses
- JMSSerializerBundle needs to be installed and enabled
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require mediamonks/rest-api-bundle "~1.0"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new MediaMonks\RestApiBundle\MediaMonksRestApiBundle(),
);
// ...
}
// ...
}
By default the event subscriber will be active on all calls that start with /api, however you can also implement the MediaMonks\RestApiBundle\RestApiControllerInterface on a controller to force the event subscriber to become active.
You can simply return a string, array, object, Symfony response or exception from a controller and it will be automatically converted into a proper output conforming to the MediaMonks Rest API Spec.