akaunting/app/Utilities/Console.php

23 lines
476 B
PHP
Raw Normal View History

2019-12-03 15:41:56 +03:00
<?php
namespace App\Utilities;
use Symfony\Component\Process\Process;
class Console
{
2020-02-05 10:24:18 +03:00
public static function run($command, $all_output = false, $timeout = 0)
2019-12-03 15:41:56 +03:00
{
2020-03-16 19:35:58 +03:00
$process = Process::fromShellCommandline($command, base_path());
2020-02-05 10:24:18 +03:00
$process->setTimeout($timeout);
2019-12-03 15:41:56 +03:00
$process->run();
if ($process->isSuccessful()) {
return true;
}
2020-01-24 15:31:03 +03:00
return $all_output ? $process->getOutput() : $process->getErrorOutput();
2019-12-03 15:41:56 +03:00
}
}