-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshowcase.php
More file actions
37 lines (29 loc) 路 865 Bytes
/
Copy pathshowcase.php
File metadata and controls
37 lines (29 loc) 路 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace App;
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Elephox\Miniphox\Miniphox;
use Elephox\Web\Routing\Attribute\Http\Get;
use Fig\Http\Message\StatusCodeInterface;
use React\Http\Message\Response;
#[Get]
function index(): string {
return "This file is being watched. The server automatically restarts if it is changed. Try it!";
}
#[Get('/redirect')]
function redirect(): Response
{
return new Response(StatusCodeInterface::STATUS_TEMPORARY_REDIRECT, ['Location' => '/api/sleep']);
}
#[Get('/sleep')]
function sleep(): string
{
usleep(1_000_000);
return "What a good sleep. Look at the timing in your network tab!";
}
Miniphox::build()
->mount('/', index(...))
->mount('/api', redirect(...), sleep(...))
->staticFiles(__DIR__ . '/static')
->watch(__FILE__)
->run();