PHPackages                             fullscreeninteractive/silverstripe-restful-helpers - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. fullscreeninteractive/silverstripe-restful-helpers

ActiveSilverstripe-vendormodule[API Development](/categories/api)

fullscreeninteractive/silverstripe-restful-helpers
==================================================

1.2.2(1y ago)32.0k3BSD-3-ClausePHPCI failing

Since Aug 24Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/fullscreeninteractive/silverstripe-restful-helpers)[ Packagist](https://packagist.org/packages/fullscreeninteractive/silverstripe-restful-helpers)[ Docs](https://github.com/fullscreeninteractive/silverstripe-restful-helpers)[ RSS](/packages/fullscreeninteractive-silverstripe-restful-helpers/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (4)Versions (7)Used By (0)

silverstripe-restful-helpers
============================

[](#silverstripe-restful-helpers)

Another module for providing some base functionality for a basic RESTFul JSON API. While everyone seems to be jumping onto GraphQL, if all you need is a quick setup with not too much configuration to get your head around, nothing beats a simple REST solution.

Handles authenication and provides common functions for serving and parsing API requests. Compared to `silverstripe-restfulserver` this module does very little scaffolding of models and fields out of the box but instead relies on developers to design the API layout (although scaffolding helpers are available)

Installation
------------

[](#installation)

```
composer require fullscreeninteractive/silverstripe-restful-helpers

```

Usage
-----

[](#usage)

If you plan on using Authenication for your API then you first need to config the [https://github.com/Level51/silverstripe-jwt-utils/](JWTUtils) module.

*app/\_config/api.yml*

```
Level51\JWTUtils\JWTUtils:
  secret: 'replace-this-with-a-jwt-secret-for-jwt'
  lifetime_in_days: 365
  renew_threshold_in_minutes: 60
```

Next step is to setup the routing for the API. You can modify the name of the routes as required for the project. At the very least you would have a project-specific end point which would subclass the `ApiController` for example, `MyProjectsApi`.

*app/\_config/routes.yml*

```
SilverStripe\Control\Director:
  rules:
    'api/v1/auth/$Action': 'FullscreenInteractive\Restful\Controllers\AuthController'
    'api/v1/projects//$Action': 'MyProjectsApi'
```

Here is an example of `MyProjectsApi` which demostrates some of the helpers provided by this module. Anyone can `GET api/v1/projects/` to retrieve a list of all projects, logged in ADMIN users can `POST api/v1/projects/create`

*app/src/Project.php*

```
