From cb5ddf7828373f2c5ed5ed5b04069be16b7a6966 Mon Sep 17 00:00:00 2001 From: Josh Salway Date: Tue, 7 Apr 2026 10:10:54 +1000 Subject: [PATCH 1/2] Fix cross-platform browser opening in OpenCommand - Use PHP_OS_FAMILY constant instead of php_uname(PHP_OS) which throws a ValueError on PHP 8.4+ (fixes #106) - Add Windows support using rundll32 (previously showed "Can't open your browser" on Windows) - Simplify OS detection with match expression Inspired by laravel/cloud-cli#117. --- app/Commands/OpenCommand.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Commands/OpenCommand.php b/app/Commands/OpenCommand.php index 25b4c4f..31bd133 100644 --- a/app/Commands/OpenCommand.php +++ b/app/Commands/OpenCommand.php @@ -34,13 +34,14 @@ public function handle() $url = "https://forge.laravel.com/servers/$serverId/sites/$siteId"; - $os = strtolower(php_uname(PHP_OS)); - - if (strpos($os, 'darwin') !== false) { - $open = 'open'; - } elseif (strpos($os, 'linux') !== false) { - $open = 'xdg-open'; - } else { + $command = match (PHP_OS_FAMILY) { + 'Darwin' => ['open', $url], + 'Linux' => ['xdg-open', $url], + 'Windows' => ['rundll32', 'url.dll,FileProtocolHandler', $url], + default => null, + }; + + if ($command === null) { $this->step("Can't open your browser, you'll have to manually navigate to {$url}"); return; @@ -48,8 +49,6 @@ public function handle() $this->step('Opening site in your browser...'); - $command = [$open, $url]; - $process = new Process($command); $process->run(); } From 2eb8e3a7de6ca3470041fa0e876a92939b16a373 Mon Sep 17 00:00:00 2001 From: Josh Salway Date: Tue, 7 Apr 2026 10:18:22 +1000 Subject: [PATCH 2/2] Use cmd /c start instead of rundll32 on Windows rundll32 url.dll,FileProtocolHandler doesn't reliably open URLs from a subprocess. cmd /c start is the standard Windows approach for opening URLs in the default browser. --- app/Commands/OpenCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Commands/OpenCommand.php b/app/Commands/OpenCommand.php index 31bd133..a2c4cc2 100644 --- a/app/Commands/OpenCommand.php +++ b/app/Commands/OpenCommand.php @@ -37,7 +37,7 @@ public function handle() $command = match (PHP_OS_FAMILY) { 'Darwin' => ['open', $url], 'Linux' => ['xdg-open', $url], - 'Windows' => ['rundll32', 'url.dll,FileProtocolHandler', $url], + 'Windows' => ['cmd', '/c', 'start', '', $url], default => null, };