PHP code example of ckunkle / httpassage
1. Go to this page and download the library: Download ckunkle/httpassage 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/ */
ckunkle / httpassage example snippets
* Create an instance of Context by passing a PSR-7 ServerRequest
* and a PSR-7 response to the constructor
*/
new \HTTPassage\Context(
\GuzzleHttp\Psr7\ServerRequest::fromGlobals(),
new \GuzzleHttp\Psr7\Response()
);
/**
* Create a Router instance and map some routes
*/
$router = new \HTTPassage\Router();
$router->get("/my/example/[a:route]", function($context) {
$route = $context->getRouteParamater("route");
$context->getResponse()->getBody()->write("You have reached $route!");
return $context;
});
/**
* Route the Context
*/
$context = $router->route($context);