Skip to content

Commit

Permalink
[2.x] Improves installation process (#785)
Browse files Browse the repository at this point in the history
* Throws error on install

* Fix code styling

* Improves `octane:install` command

---------

Co-authored-by: nunomaduro <[email protected]>
  • Loading branch information
nunomaduro and nunomaduro authored Dec 21, 2023
1 parent cd8e205 commit 7df6da4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/Commands/Concerns/InstallsFrankenPhpDependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -53,7 +54,7 @@ protected function ensureFrankenPhpBinaryIsInstalled()
/**
* Download the latest version of the FrankenPHP binary.
*
* @return string|false
* @return string
*/
protected function downloadFrankenPhpBinary()
{
Expand All @@ -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')
Expand Down Expand Up @@ -114,9 +113,7 @@ protected function downloadFrankenPhpBinary()
return $path;
}

$this->error('FrankenPHP asset not found.');

return false;
throw new RuntimeException('FrankenPHP asset not found.');
}

/**
Expand Down Expand Up @@ -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");
Expand Down
11 changes: 10 additions & 1 deletion src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
use Laravel\Octane\Swoole\SwooleExtension;
use Throwable;

class InstallCommand extends Command
{
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 7df6da4

Please sign in to comment.