find the php binary in console
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user