Skip to content

Commit 6300617

Browse files
authored
feat(console): ensure tempest serve supports routes with file extension (#704)
1 parent 2a73033 commit 6300617

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Tempest/Http/src/Commands/ServeCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
)]
1515
public function __invoke(string $host = 'localhost', int $port = 8000, string $publicDir = 'public/'): void
1616
{
17-
passthru("php -S {$host}:{$port} -t {$publicDir}");
17+
putenv("TEMPEST_PUBLIC_DIR={$publicDir}");
18+
$routerFile = __DIR__ . '/router.php';
19+
passthru("php -S {$host}:{$port} -t {$publicDir} {$routerFile}");
1820
}
1921
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
$publicPath = getcwd() . '/' . rtrim($_ENV['TEMPEST_PUBLIC_DIR'], '/');
6+
7+
if (file_exists($publicPath . $_SERVER['REQUEST_URI'])) {
8+
return false;
9+
}
10+
11+
require_once $publicPath . '/index.php';

0 commit comments

Comments
 (0)