2017 © Pedro Peláez
 

library restserver

rest services made easy, restServer: PSR http message, builtin ip, cors, auth, serializers and decoders

image

kigkonsult/restserver

rest services made easy, restServer: PSR http message, builtin ip, cors, auth, serializers and decoders

  • Monday, July 2, 2018
  • by kigsf
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

restServer - rest services made easy

restServer provides, (*1)

  • a PSR HTTP message rest server
  • builtin ip, cors, auth, serializing and decoding mgnt
  • API for your application

Install

To install with composer:, (*2)

composer require kigkonsult/restserver

Requires PHP 5.6, 7.*, (*3)

Usage

Example usage:, (*4)

<?php

require '/path/to/vendor/autoload.php';

// Implement an application rest service operation entry
// (or any callable with the same interface)
$callback = function(
    ServerRequestInterface $request,
    ResponseInterface      $response
) {
    return $response->withRawBody( [ 'Hello' => 'world' ] );
};

// Set up the rest service definition (method, uri and callback)
$restGetServiceDef = [
    RestServer::METHOD   => RequestMethodHandler::METHOD_GET,
    RestServer::URI      => '/',
    RestServer::CALLBACK => $callback
];

// Attach the rest service(s) and fire of the server
RestServer::factory()->attachRestService( $restGetServiceDef )->run();

More example usage:, (*5)

<?php

require '/path/to/vendor/autoload.php';

$RestServer = new RestServer();

$attachRestServiceCallback = $RestServer->getAttachRestServiceCallback();

class ApplicationClass2
{
    public function registerAsRestService(
        $attachRestServiceCallback
    ) {
        $attachRestServiceCallback(
            RequestMethodHandler::METHOD_GET,
            '/',
            [$this, 'action']
        );
    }

    public function action(
        ServerRequestInterface $request,
        ResponseInterface      $response
    ) {
        return $response->withRawBody( ['msg' => 'Hello world'] );
    }
}

$ApplicationClass2 = new ApplicationClass2();
$ApplicationClass2->registerAsRestService( $attachRestServiceCallback );

$RestServer->run();

Rest service definition

You have to implement one or more rest service (callable) entries for your application logic. Each entry with one or more http request methods and a (single) uri (ex '/') form a service definition. The service definitions, attached to restServer, are interfaces to your application logic., (*6)

Handlers

restServer have builtin handlers managing IPnumber validation, Cross-Origin Resource Sharing, authentication, messages serializing and en-/decoding. As well as rest service definitions, you can attach custom request message handler(s), invoked before any operation callback. Also a custom (single) final handler can be attached, invoked after response is returned., (*7)

Documentation

In the restServer package docs folder are found - summary and supplementary documentation - demo applications and service definitions - demo handlers - more examples, (*8)

For restServer issues, use github. Due to the restServer development status (ver 0.9.123), review reports are appreciated!, (*9)

Credits and base software information

Built status

Dev 0.9.123, (*10)

The Versions

02/07 2018

dev-master

9999999-dev https://github.com/iCalcreator/restserver

rest services made easy, restServer: PSR http message, builtin ip, cors, auth, serializers and decoders

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

02/07 2018

v0.9.123

0.9.123.0 https://github.com/iCalcreator/restserver

rest services made easy, restServer: PSR http message, builtin ip, cors, auth, serializers and decoders

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

14/04 2018

v0.9.26

0.9.26.0 https://github.com/iCalcreator/restserver

rest services made easy, restServer, based on PSR http message, builtin serializers and decoders

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

12/04 2018

v0.9.25

0.9.25.0 https://github.com/iCalcreator/restserver

rest services made easy, restServer, based on PSR http message, builtin serializers and decoders

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

10/04 2018

v0.9.24

0.9.24.0 https://github.com/iCalcreator/restserver

rest services made easy, restServer, based on PSR http message, builtin serializers and decoders

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

10/04 2018

v0.9.23

0.9.23.0 https://github.com/iCalcreator/restserver

rest services made easy, restServer, based on PSR http message, builtin serializers and decoders

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

31/03 2018

v0.8.4

0.8.4.0 https://github.com/iCalcreator/restserver

REST server based on psr, zend-diactoros and fast-route

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

30/03 2018

v0.8.3

0.8.3.0 https://github.com/iCalcreator/restserver

REST server based on psr, zend-diactoros and fast-route

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message

30/03 2018

v0.8.2

0.8.2.0 https://github.com/iCalcreator/restserver

REST server based on psr, zend-diactoros and zend-diactoros

  Sources   Download

AGPL-1.0

The Requires

 

The Development Requires

psr psr-7 service rest server http request response http-message