REST module for Silverstripe
This module models the REST api in a simple fashion.
All routes for the different resources should resolved by a controller which extends the BaseRestController.
After that, you can add your routes into your YAML config file.
- Field list
- Different serialisation formats
For the definition of your routes, use the Silverstripe config system. You can add nested routes before the base route
of that endpoint. In this example we have
Director: rules: 'v/1/users/$ID!/friends/$FriendID': 'FriendshipController' 'v/1/users/$ID': 'UserController' 'v/1/sessions/$ID': 'Ntb\RestAPI\SessionController'
If you visit your api through a browser, the controller will render it as html as long as you not specify an
GET param, eg.
You can specify the access token with
access_token. This can be used for accessing restricted resources with specific
For functional tests, you can extend the
RestTest class and use it to test your application. We recommend to use
fixtures for testing like it is explained in the Silverstripe documentation.
You can find more information in the wiki.