2017 © Pedro Peláez
 

library silex-restful

Silex 2.0+ service provider for RESTful middleware

image

lokhman/silex-restful

Silex 2.0+ service provider for RESTful middleware

  • Wednesday, April 19, 2017
  • by lokhman
  • Repository
  • 1 Watchers
  • 0 Stars
  • 333 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

silex-restful

StyleCI, (*1)

RESTful middleware service provider for Silex 2.0+ micro-framework., (*2)

This project is a part of silex-tools library., (*3)

Installation

You can install silex-restful with Composer:, (*4)

composer require lokhman/silex-restful

Documentation

Registering RestfulServiceProvider will easily extend your application routing with JSON request/response methods, error handing and JSON parameter acceptance. It works in the same way as Silex routing binding (get, post, etc), supports own controllers_factory and mount functionality., (*5)

use Lokhman\Silex\Provider\RestfulServiceProvider;

$app->register(new RestfulServiceProvider());

// response is transformed to JSON string
$app['restful']->get('/api', function() {
    return ['version' => '1.0'];
});

// can mount controller collections
$app['restful']->mount('/api/v2', function($api) {
    // accepts parameters from "application/json" body
    $api->post('/submit', function(Request $request) {
        return ['params' => $request->request->all()];
    });
});

// can mount controller providers
class ApiBundle implements ControllerProviderInterface {

    function connect(Application $app) {
        $factory = $app['restful.controllers_factory'];

        $factory->get('/', function() {
            // will modify all exceptions to JSON compatible responses
            throw new GoneHttpException('API v3 is not supported anymore.');
        });

        return $factory->getControllerCollection();
    }

}

$app->mount('/api/v3', new ApiBundle());

License

Library is available under the MIT license. The included LICENSE file describes this in detail., (*6)

The Versions

19/04 2017

dev-master

9999999-dev

Silex 2.0+ service provider for RESTful middleware

  Sources   Download

MIT

The Requires

 

by Alexander Lokhman

silex restful tools

19/04 2017

2.0.2

2.0.2.0

Silex 2.0+ service provider for RESTful middleware

  Sources   Download

MIT

The Requires

 

by Alexander Lokhman

silex restful tools

06/03 2017

2.0.1

2.0.1.0

Silex 2.0+ service provider for RESTful middleware

  Sources   Download

MIT

The Requires

 

by Alexander Lokhman

silex restful tools

24/01 2017

2.0.0

2.0.0.0

Silex 2.0+ service provider for RESTful middleware

  Sources   Download

MIT

The Requires

 

by Alexander Lokhman

silex restful tools