Installing and configuring REST features
First, we will need to install our bundles by typing the following:
$ composer require jms/serializer-bundle $ composer require friendsofsymfony/rest-bundle $ composer require friendsofsymfony/jsrouting-bundle $ composer require nelmio/api-doc-bundle
Then, we need to modify the AppKernel.php
file, and add our new bundles as follows:
// other bundles new JMS\SerializerBundle\JMSSerializerBundle(), new FOS\RestBundle\FOSRestBundle(), new FOS\JsRoutingBundle\FOSJsRoutingBundle(), new Nelmio\ApiDocBundle\NelmioApiDocBundle(), );
This will activate the bundles. Some of them require a little additional configuration steps.
FOSRestBundle
We will start our configuration with FOSRestBundle
. This bundle is used to automate request and response handling. It allows you to create routings based just on your action name. Also, the bundle guesses what kind of request you may need (POST
, PUT
, DELETE
, or other), and tries to define the optimal...