Search code examples
restcontrollertypo3-flow

FLOW3 Restcontroller


I would like to set up a Rest Controller in flow3. I have checked the Restcontroller class, but I actually didn't understand what should I do in order to make a derived class to work. I mean:

class myRestController extends TYPO3\FLOW3\MVC\Controller\RestController{
...
}

And how should I set up the routing?

Thanks! David


Solution

  • First, your controller should be named MyRestController and not myRestController. (Flow3 code guidelines)

    Second, in a Routes.yaml (probably in your package) file place:

       name: 'RouteName'                                                                                                                                                                                                                                                     
         uriPattern: 'rest/myrest'
         defaults:
           '@package':    'Your.Complete.Package.Name'
           '@controller': 'MyRest'
           '@format':     'json'
    

    Lastly implement the methods

    index - for http get without resource show - for http get with resource create - for http post update - for http put delete - for http delete