From 1ebf2aab70b941edad580bea49ebfb88610e897e Mon Sep 17 00:00:00 2001 From: Vincent Hagen Date: Fri, 8 Nov 2024 22:06:17 +0100 Subject: [PATCH] feat(console): Ensure serve supports routes with file extension --- src/Tempest/Http/src/Commands/ServeCommand.php | 4 +++- src/Tempest/Http/src/Commands/router.php | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/Tempest/Http/src/Commands/router.php diff --git a/src/Tempest/Http/src/Commands/ServeCommand.php b/src/Tempest/Http/src/Commands/ServeCommand.php index 27168bce0..9ded5e961 100644 --- a/src/Tempest/Http/src/Commands/ServeCommand.php +++ b/src/Tempest/Http/src/Commands/ServeCommand.php @@ -14,6 +14,8 @@ )] public function __invoke(string $host = 'localhost', int $port = 8000, string $publicDir = 'public/'): void { - passthru("php -S {$host}:{$port} -t {$publicDir}"); + 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 new file mode 100644 index 000000000..0205897f2 --- /dev/null +++ b/src/Tempest/Http/src/Commands/router.php @@ -0,0 +1,12 @@ +