1. Go to this page and download the library: Download legionth/http-rest library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
legionth / http-rest example snippets
$loop = \React\EventLoop\Factory::create();
$server = new \Legionth\React\Http\Rest\Server();
$server->get('/say/hello', function (\Psr\Http\Message\ServerRequestInterface $request, callable $next) {
return new \React\Http\Response(200, array(), 'hello');
});
$socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop);
$server->listen($socket);
$loop->run();