From 38532938d1ea180ca3a64d809c20085e1178d38e Mon Sep 17 00:00:00 2001 From: John Zhang Date: Mon, 11 Oct 2021 10:10:52 +0800 Subject: [PATCH] fixed several compatibility issues with windows and php-cgi --- src/Scheduling.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Scheduling.php b/src/Scheduling.php index d0bae5f..db21d1a 100644 --- a/src/Scheduling.php +++ b/src/Scheduling.php @@ -75,6 +75,15 @@ protected function formatTask($event) ]; } + if (PHP_OS_FAMILY === 'Windows' && Str::contains($event->command, '"artisan"')) { + $exploded = explode(' ', $event->command); + + return [ + 'type' => 'artisan', + 'name' => 'artisan '.implode(' ', array_slice($exploded, 2)), + ]; + } + return [ 'type' => 'command', 'name' => $event->command, @@ -95,6 +104,10 @@ public function runTask($id) /** @var \Illuminate\Console\Scheduling\Event $event */ $event = $this->getKernelEvents()[$id - 1]; + if (PHP_OS_FAMILY === 'Windows') { + $event->command = Str::of($event->command)->replace('php-cgi.exe', 'php.exe'); + } + $event->sendOutputTo($this->getOutputTo()); $event->run(app());