2017 © Pedro Peláez
 

library rest-server

Library to easily expose REST APIs

image

innmind/rest-server

Library to easily expose REST APIs

  • Tuesday, May 8, 2018
  • by Baptouuuu
  • Repository
  • 2 Watchers
  • 2 Stars
  • 20,547 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 24 Versions
  • 3 % Grown

The README.md

REST Server

Build Status codecov Type Coverage, (*1)

This library contains a set of tools to define, validate, extract and expose resources through http in a REST manner., (*2)

Installation

Via composer:, (*3)

composer require innmind/rest-server

Usage

use function Innmind\Rest\Server\bootstrap;
use Innmind\Rest\Server\Gateway;
use Innmind\Immutable\Map;

$services = bootstrap(
    new Map('string', Gateway::class),
    require '/path/to/resources/mapping.php'
);

$services['routes']; // provides all the routes available for the definitions you provided

// action controllers
$services['controller']['create'];
$services['controller']['index'];
$services['controller']['get'];
$services['controller']['remove'];
$services['controller']['update'];
$services['controller']['link'];
$services['controller']['unlink'];
// controller to output the resource definition
$services['controller']['options'];
// controller to expose links to all the resources definitions
$services['controller']['capabilities'];

The gateways are the bridges between this component and your domain. The definition handling which resource is handled by which gateway is done in the resources mapping where a resource can only be managed by one gateway. Take a look at fixtures/mapping.php to understand how to define your resources., (*4)

The Versions