diff --git a/app/Commands/OpenCommand.php b/app/Commands/OpenCommand.php index 25b4c4f..a2c4cc2 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' => ['cmd', '/c', 'start', '', $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(); }