gonzalo123 / httpserver
HTTP server in PHP. Using reactphp or Built-In Server
dev-master
2013-11-07 22:27 UTC
Requires
- react/react: 0.4.*@dev
Requires (Dev)
- silex/silex: 1.1.*@dev
- symfony/process: 2.4.*@dev
This package is not auto-updated.
Last update: 2024-12-16 15:26:04 UTC
README
Starting the Built-In PHP Webserver and handling requests
Returning a simple text response
use G\HttpServer\Builder; use Symfony\Component\HttpFoundation\Request; Builder::createBuiltInServer(function (Request $request) { return "Hello " . $request->get('name'); })->listen(1337);
Returning a Response (one Silex application)
use G\HttpServer\Builder; use Symfony\Component\HttpFoundation\Request; $app = new Silex\Application(); $app->get('/', function () { return 'Hello'; }); $app->get('/hello/{name}', function ($name) { return 'Hello ' . $name; }); Builder::createBuiltInServer(function (Request $request) use ($app) { return $app->handle($request); })->listen(1337);
Starting one React Webserver and handling requests
https://github.com/reactphp/react
Returning a simple text response
use G\HttpServer\Builder; use Symfony\Component\HttpFoundation\Request; Builder::createReactServer(function (Request $request) { return "Hello " . $request->get('name'); })->listen(1337);
Returning a Response (one Silex application)
use G\HttpServer\Builder; use Symfony\Component\HttpFoundation\Request; $app = new Silex\Application(); $app->get('/', function () { return 'Hello'; }); $app->get('/hello/{name}', function ($name) { return 'Hello ' . $name; }); Builder::createReactServer(function (Request $request) use ($app) { return $app->handle($request); })->listen(1337);