mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-07 16:55:38 +08:00
Add initial windows runtime setup (#292)
* add initial windows runtime setup * add cool console output * doctor support windows base * add `add-path` and `remove-path` for bin/setup-runtime * fix composer.ps1 path * add windows system util * add windows cmd and doctor base check * add windows fallback for laravel/prompts * cd fix [skip ci] * dir separator and typo fix [skip ci]
This commit is contained in:
44
src/SPC/doctor/item/WindowsToolCheckList.php
Normal file
44
src/SPC/doctor/item/WindowsToolCheckList.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\doctor\item;
|
||||
|
||||
use SPC\builder\windows\SystemUtil;
|
||||
use SPC\doctor\AsCheckItem;
|
||||
use SPC\doctor\AsFixItem;
|
||||
use SPC\doctor\CheckResult;
|
||||
use SPC\exception\RuntimeException;
|
||||
|
||||
class WindowsToolCheckList
|
||||
{
|
||||
#[AsCheckItem('if git are installed', limit_os: 'Windows', level: 999)]
|
||||
public function checkGit(): ?CheckResult
|
||||
{
|
||||
if (SystemUtil::findCommand('git.exe') === null) {
|
||||
return CheckResult::fail('Git not installed, please install git for windows manually, see: https://git-scm.com/download/win');
|
||||
// return CheckResult::fail('Git not installed, see https://static-php.dev/en/guide/windows-setup.html');
|
||||
}
|
||||
return CheckResult::ok();
|
||||
}
|
||||
|
||||
#[AsCheckItem('if php-sdk-binary-tools are downloaded', limit_os: 'Windows', level: 998)]
|
||||
public function checkSDK(): ?CheckResult
|
||||
{
|
||||
if (!file_exists(PHP_SDK_PATH . DIRECTORY_SEPARATOR . 'phpsdk-starter.bat')) {
|
||||
return CheckResult::fail('php-sdk-binary-tools not downloaded', 'install-php-sdk');
|
||||
}
|
||||
return CheckResult::ok(PHP_SDK_PATH);
|
||||
}
|
||||
|
||||
#[AsFixItem('install-php-sdk')]
|
||||
public function installPhpSdk(): bool
|
||||
{
|
||||
try {
|
||||
cmd(true)->exec('git clone https://github.com/php/php-sdk-binary-tools.git ' . PHP_SDK_PATH);
|
||||
} catch (RuntimeException) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user