Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 479 Bytes

File metadata and controls

20 lines (13 loc) · 479 Bytes

Basic Web Surface

<?php

declare(strict_types=1);

use CommonPHP\HTTP\HttpApplication;
use CommonPHP\Web\WebSurface;

$web = new WebSurface(pathPrefix: '/');

$web->get('/', static fn (): string => '<h1>Home</h1>', 'home');
$web->get('/about', static fn (): string => '<h1>About</h1>', 'about');

$app = (new HttpApplication())
    ->surface('web', $web, '/');

The route callbacks return HTML strings, which PageResponseFactory turns into text/html responses.