Skip to content

Commit

Permalink
find the php binary in console
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 19, 2020
1 parent 9748b48 commit 437cbd3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/UpdateAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function runUpdate($alias)

$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]);
Expand Down
2 changes: 1 addition & 1 deletion app/Traits/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function installModule($path)

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,
Expand Down
20 changes: 19 additions & 1 deletion app/Utilities/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -19,4 +22,19 @@ public static function run($command, $all_output = false, $timeout = 0)

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);
}
}
2 changes: 1 addition & 1 deletion app/Utilities/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static function checkServerRequirements()
$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');
}

Expand Down
2 changes: 1 addition & 1 deletion app/Utilities/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static function finish($alias, $new, $old)
}

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]);
Expand Down

0 comments on commit 437cbd3

Please sign in to comment.