diff --git a/src/Commands/Concerns/InstallsFrankenPhpDependencies.php b/src/Commands/Concerns/InstallsFrankenPhpDependencies.php index 8e90798e9..cf33cde38 100644 --- a/src/Commands/Concerns/InstallsFrankenPhpDependencies.php +++ b/src/Commands/Concerns/InstallsFrankenPhpDependencies.php @@ -6,6 +6,7 @@ use Illuminate\Support\Facades\Http; use Illuminate\Support\Str; use Laravel\Octane\FrankenPhp\Concerns\FindsFrankenPhpBinary; +use RuntimeException; use Symfony\Component\Process\Process; use Throwable; @@ -53,7 +54,7 @@ protected function ensureFrankenPhpBinaryIsInstalled() /** * Download the latest version of the FrankenPHP binary. * - * @return string|false + * @return string */ protected function downloadFrankenPhpBinary() { @@ -66,9 +67,7 @@ protected function downloadFrankenPhpBinary() }; if ($assetName === null) { - $this->error('FrankenPHP binaries are currently only available for Linux (x86_64) and macOS. Other systems should use the Docker images or compile FrankenPHP manually.'); - - return false; + throw new RuntimeException('FrankenPHP binaries are currently only available for Linux (x86_64) and macOS. Other systems should use the Docker images or compile FrankenPHP manually.'); } $assets = Http::accept('application/vnd.github+json') @@ -114,9 +113,7 @@ protected function downloadFrankenPhpBinary() return $path; } - $this->error('FrankenPHP asset not found.'); - - return false; + throw new RuntimeException('FrankenPHP asset not found.'); } /** @@ -166,7 +163,7 @@ protected function ensureFrankenPhpBinaryMeetsRequirements($frankenPhpBinary) rename("$frankenPhpBinary.backup", $frankenPhpBinary); - return $this->warn('Unable to download FrankenPHP binary. The HTTP request exception has been logged.'); + return $this->warn('Unable to download FrankenPHP binary. The underlying error has been logged.'); } unlink("$frankenPhpBinary.backup"); diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 3608dbb0a..4b25925f0 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\File; use Illuminate\Support\Str; use Laravel\Octane\Swoole\SwooleExtension; +use Throwable; class InstallCommand extends Command { @@ -145,7 +146,15 @@ public function installFrankenPhpServer() $this->ensureFrankenPhpWorkerIsInstalled(); - return $this->ensureFrankenPhpBinaryIsInstalled(); + try { + $this->ensureFrankenPhpBinaryIsInstalled(); + } catch (Throwable $e) { + $this->error($e->getMessage()); + + return false; + } + + return true; } /**