Created
September 21, 2017 17:35
-
-
Save deleugpn/21dae56b0a6c15866dba59867607dedf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App; | |
use Symfony\Component\Process\Exception\ProcessFailedException; | |
use Symfony\Component\Process\Process as SymfonyProcess; | |
class Process | |
{ | |
public function run($command, $directory = null) | |
{ | |
$directory = $directory ?: base_path(); | |
$process = new SymfonyProcess($command); | |
$process->setTimeout(30); | |
$process->setIdleTimeout(30); | |
$process->setWorkingDirectory($directory); | |
try { | |
$process->mustRun(); | |
return $process->getOutput(); | |
} catch (ProcessFailedException $e) { | |
return $e->getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment