Skip to content

Commit

Permalink
feat(console): Ensure serve supports routes with file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
blackshadev committed Nov 8, 2024
1 parent 2a73033 commit 1ebf2aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Tempest/Http/src/Commands/ServeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}
}
12 changes: 12 additions & 0 deletions src/Tempest/Http/src/Commands/router.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

$publicPath = getcwd() . '/' . rtrim($_ENV['TEMPEST_PUBLIC_DIR'], '/');

if (file_exists($publicPath . $_SERVER['REQUEST_URI'])) {
return false;
}

require_once $publicPath . '/index.php';

0 comments on commit 1ebf2aa

Please sign in to comment.