-
Notifications
You must be signed in to change notification settings - Fork 0
Dispatching a Router
Joshua Parker edited this page Dec 23, 2020
·
4 revisions
You can dispatch a router by using Laminas SapiEmitter in combination with ServerRequest
or use ServerRequest
in combination with HttpPublisher
.
/**
* Step 4: Dispath the router.
*/
use Qubus\Http\ServerRequest;
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter as EmitResponse;
return (new EmitResponse)->emit(
$router->match(
ServerRequest::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
)
)
);
/**
* Or you can use the HttpPublisher:
*/
use Qubus\Http\ServerRequest;
use Qubus\Http\HttpPublisher;
return (new HttpPublisher)->publish(
$router->match(
ServerRequest::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
)
),
null
);