From ccc1eced75392945798173189fbe51e044fcd947 Mon Sep 17 00:00:00 2001 From: samir Date: Tue, 12 Nov 2024 12:56:21 +0100 Subject: [PATCH] fix(http): use document root instead of env in `tempest serve` (#717) --- src/Tempest/Http/src/Commands/ServeCommand.php | 1 - src/Tempest/Http/src/Commands/router.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Tempest/Http/src/Commands/ServeCommand.php b/src/Tempest/Http/src/Commands/ServeCommand.php index 9ded5e961..f00e3b629 100644 --- a/src/Tempest/Http/src/Commands/ServeCommand.php +++ b/src/Tempest/Http/src/Commands/ServeCommand.php @@ -14,7 +14,6 @@ )] public function __invoke(string $host = 'localhost', int $port = 8000, string $publicDir = 'public/'): void { - putenv("TEMPEST_PUBLIC_DIR={$publicDir}"); $routerFile = __DIR__ . '/router.php'; passthru("php -S {$host}:{$port} -t {$publicDir} {$routerFile}"); } diff --git a/src/Tempest/Http/src/Commands/router.php b/src/Tempest/Http/src/Commands/router.php index 35960037d..0f5e0f6ba 100644 --- a/src/Tempest/Http/src/Commands/router.php +++ b/src/Tempest/Http/src/Commands/router.php @@ -2,7 +2,7 @@ declare(strict_types=1); -$publicPath = getcwd() . '/' . rtrim($_ENV['TEMPEST_PUBLIC_DIR'], '/'); +$publicPath = $_SERVER['DOCUMENT_ROOT']; if (file_exists($publicPath . $_SERVER['REQUEST_URI'])) { return false;