for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App;
class Executor
{
/**
* @param string|array $scriptPath
*/
public function executeCommand($scriptPath, array $env)
$oldCwd = NULL;
if (is_array($scriptPath)) {
if (isset($scriptPath['cwd'])) {
$cwd = $scriptPath['cwd'];
unset($scriptPath['cwd']);
$oldCwd = getcwd();
chdir($cwd);
}
$commands = $scriptPath;
} else {
$commands = [$scriptPath];
foreach ($env as $key => $value) {
putenv($key . '=' . $value);
foreach ($commands as $command) {
shell_exec($command);
if ($oldCwd !== NULL) {
chdir($oldCwd);