mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-11 19:05:35 +08:00
doctor support windows base
This commit is contained in:
@@ -75,8 +75,9 @@ class DoctorCommand extends BaseCommand
|
|||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->output->writeln('<error>' . $e->getMessage() . '</error>');
|
$this->output->writeln('<error>' . $e->getMessage() . '</error>');
|
||||||
|
|
||||||
pcntl_signal(SIGINT, SIG_IGN);
|
if (extension_loaded('pcntl')) {
|
||||||
|
pcntl_signal(SIGINT, SIG_IGN);
|
||||||
|
}
|
||||||
return static::FAILURE;
|
return static::FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,23 @@ final class CheckListHandler
|
|||||||
*/
|
*/
|
||||||
public function emitFix(OutputInterface $output, CheckResult $result): void
|
public function emitFix(OutputInterface $output, CheckResult $result): void
|
||||||
{
|
{
|
||||||
pcntl_signal(SIGINT, function () use ($output) {
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
$output->writeln('<error>You cancelled fix</error>');
|
sapi_windows_set_ctrl_handler(function () use ($output) {
|
||||||
});
|
$output->writeln('<error>You cancelled fix</error>');
|
||||||
|
});
|
||||||
|
} elseif (extension_loaded('pcntl')) {
|
||||||
|
pcntl_signal(SIGINT, function () use ($output) {
|
||||||
|
$output->writeln('<error>You cancelled fix</error>');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams());
|
$fix_result = call_user_func($this->fix_map[$result->getFixItem()], ...$result->getFixParams());
|
||||||
pcntl_signal(SIGINT, SIG_IGN);
|
|
||||||
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
|
sapi_windows_set_ctrl_handler(null);
|
||||||
|
} elseif (extension_loaded('pcntl')) {
|
||||||
|
pcntl_signal(SIGINT, SIG_IGN);
|
||||||
|
}
|
||||||
|
|
||||||
if ($fix_result) {
|
if ($fix_result) {
|
||||||
$output->writeln('<info>Fix done</info>');
|
$output->writeln('<info>Fix done</info>');
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class OSCheckList
|
|||||||
public function checkOS(): ?CheckResult
|
public function checkOS(): ?CheckResult
|
||||||
{
|
{
|
||||||
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) {
|
if (!in_array(PHP_OS_FAMILY, ['Darwin', 'Linux', 'BSD'])) {
|
||||||
return CheckResult::fail('Current OS is not supported');
|
return CheckResult::fail('Current OS is not supported: ' . PHP_OS_FAMILY);
|
||||||
}
|
}
|
||||||
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
|
$distro = PHP_OS_FAMILY === 'Linux' ? (' ' . SystemUtil::getOSRelease()['dist']) : '';
|
||||||
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');
|
return CheckResult::ok(PHP_OS_FAMILY . ' ' . php_uname('m') . $distro . ', supported');
|
||||||
|
|||||||
Reference in New Issue
Block a user