PHP code example of mariuslundgard / php-server
1. Go to this page and download the library: Download mariuslundgard/php-server 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/ */
mariuslundgard / php-server example snippets
(new Server\Module())
->map([
'fn' => function ($req, $res) {
$res->write('<h1>Hello, world</h1>');
}
])
->call() // calls the application
->send(); // outputs the headers and response body
class HeaderFilter extends Server\Layer
{
public function call(Server\Request $req = null, Server\Error $err = null)
{
$res = parent::call($req, $err);
$res->body = '<h1>'.$res->body.'</h1>';
return $res;
}