diff --git a/app/Console/Commands/UpdateAll.php b/app/Console/Commands/UpdateAll.php index c61167ad0..df4fc26b3 100644 --- a/app/Console/Commands/UpdateAll.php +++ b/app/Console/Commands/UpdateAll.php @@ -59,7 +59,7 @@ class UpdateAll extends Command $company_id = $this->argument('company'); - $command = "php artisan update {$alias} {$company_id}"; + $command = "update {$alias} {$company_id}"; if (true !== $result = Console::run($command, true)) { $message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]); diff --git a/app/Traits/Modules.php b/app/Traits/Modules.php index e6bcfaad2..195d9012b 100644 --- a/app/Traits/Modules.php +++ b/app/Traits/Modules.php @@ -406,7 +406,7 @@ trait Modules Cache::forget('installed.' . $company_id . '.module'); - Console::run("php artisan module:install {$module->alias} {$company_id} {$locale}"); + Console::run("module:install {$module->alias} {$company_id} {$locale}"); return [ 'success' => true, diff --git a/app/Utilities/Console.php b/app/Utilities/Console.php index 3e0e5d495..399a7f1ef 100644 --- a/app/Utilities/Console.php +++ b/app/Utilities/Console.php @@ -2,12 +2,15 @@ namespace App\Utilities; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\Process; class Console { - public static function run($command, $all_output = false, $timeout = 0) + public static function run($string, $all_output = false, $timeout = 0) { + $command = static::formatCommandString($string); + $process = Process::fromShellCommandline($command, base_path()); $process->setTimeout($timeout); @@ -19,4 +22,19 @@ class Console return $all_output ? $process->getOutput() : $process->getErrorOutput(); } + + public static function getPhpBinary() + { + return (new PhpExecutableFinder)->find(false) ?? 'php'; + } + + public static function getArtisanBinary() + { + return defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan'; + } + + public static function formatCommandString($string) + { + return sprintf('%s %s %s', static::getPhpBinary(), static::getArtisanBinary(), $string); + } } diff --git a/app/Utilities/Installer.php b/app/Utilities/Installer.php index d89620f91..316d44632 100644 --- a/app/Utilities/Installer.php +++ b/app/Utilities/Installer.php @@ -116,7 +116,7 @@ class Installer $requirements[] = trans('install.requirements.directory', ['directory' => 'storage/logs']); } - if (Console::run('php artisan help') !== true) { + if (Console::run('help') !== true) { $requirements[] = trans('install.requirements.executable'); } diff --git a/app/Utilities/Updater.php b/app/Utilities/Updater.php index 973741677..f889b640f 100644 --- a/app/Utilities/Updater.php +++ b/app/Utilities/Updater.php @@ -135,7 +135,7 @@ class Updater } foreach ($companies as $company) { - $command = "php artisan update:finish {$alias} {$company} {$new} {$old}"; + $command = "update:finish {$alias} {$company} {$new} {$old}"; if (true !== $result = Console::run($command)) { $message = !empty($result) ? $result : trans('modules.errors.finish', ['module' => $alias]);