PHP code example of cormy / server-request-handler
1. Go to this page and download the library: Download cormy/server-request-handler 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/ */
cormy / server-request-handler example snippets
use Cormy\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response;
class RequestHandler implements RequestHandlerInterface
{
/**
* Process an incoming server request and return the response.
*
* @param ServerRequestInterface $request
*
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request):ResponseInterface
{
$response = new Response();
$response = $response->withHeader('content-type', 'application/json; charset=utf-8');
// ...
return $response;
}
}