2017 © Pedro Peláez
 

library react-restify

Create RESTful API with ReactPHP

image

esokullu/react-restify

Create RESTful API with ReactPHP

  • Wednesday, June 27, 2018
  • by esokullu
  • Repository
  • 1 Watchers
  • 0 Stars
  • 69 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 11 Versions
  • 19 % Grown

The README.md

React-Restify

Scrutinizer Code Quality, (*1)

RESTful api made easy for ReactPHP, seriously., (*2)

Instalation

Via composer, (*3)

``` bash $ composer require capmousse/react-restify, (*4)



## Create server Here is an exemple of a simple HTTP server replying to all get call like `http://127.0.0.1:1337/hello/you` ``` php require 'vendor/autoload.php'; $server = new CapMousse\ReactRestify\Server("MyAPP", "0.0.0.1"); // Middleware $server->use(function ($request, $next) { print_r($request->getMethod()); $next(); }); // Dependency injection $server->add(\Foo\Bar::class) $server->get('/hello/{name}', function ($request, $response, \Foo\Bar $bar, $name) { $response ->write("Hello {$name}") ->end(); $bar->foobar(); }); $server->listen(1337);

To create a secure HTTPS server, you need to give all your cert files to the server :, (*5)

``` php $server->listen(1337, "[::1]", [ 'local_cert' => DIR . 'localhost.pem' ]);, (*6)

More examples can be found on the example directory like the **Todo** example.

## Controller, Middleware and Dependency injection

React-Restify support Controller call, middleware *à la express* and Dependency Injection.

``` php

use CapMousse\ReactRestify\Http\Request;
use CapMousse\ReactRestify\Http\Response;

class Foo {
    public function bar() {
        echo "Do something";
    }
}

class FooBar {
    public function baz (Response $response, Foo $foo) {
        $foo->bar();
        $response->end()
    }
}

$server->add(Foo::class);

$server->use(function ($request, $next) {
    echo $request->httpRequest->getPath();
});

$server->get('/', 'FooBar@baz');

Design goals

React-Restify was primary made to build RESTful api easily. It can be used like Silex or Express., (*7)

Next part will be to support Sockets, Upgrade Requests... to create a real time API server., (*8)

Licence

MIT, see LICENCE file, (*9)

The Versions

27/06 2018

dev-master

9999999-dev

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

20/08 2017

dev-patch-1

dev-patch-1

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

20/08 2017

dev-esokullu-patch-3

dev-esokullu-patch-3

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

20/08 2017

1.1.2

1.1.2.0

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

20/08 2017

dev-esokullu-patch-2

dev-esokullu-patch-2

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

20/08 2017

dev-esokullu-patch-1

dev-esokullu-patch-1

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

21/03 2017

1.1.1

1.1.1.0

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

The Development Requires

rest react restify

22/02 2017

1.1.0

1.1.0.0

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

rest react restify

20/02 2017

1.0.0

1.0.0.0

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

rest react restify

04/04 2014

0.2.0

0.2.0.0

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

rest react restify

28/03 2014

0.1.0

0.1.0.0

Create RESTful API with ReactPHP

  Sources   Download

MIT

The Requires

 

rest react restify