Skip to content

Latest commit

 

History

History
28 lines (25 loc) · 676 Bytes

bash-process-component.md

File metadata and controls

28 lines (25 loc) · 676 Bytes

The Symfony Process Component in Laravel

The Symfony Process Component is included with Laravel, here's an example of executing a command.

<?php
$process = Process::fromShellCommandline(
    "ssh -C forge@hostname \"mysqldump staging\" | mysql staging"
);
$process->setTimeout(60*10);
$process->setTty(Process::isTtySupported());
$process->setEnv(array(
    "PATH" => implode(':', array(
        "/usr/local/bin",
        "/usr/bin",
        "/usr/sbin",
        "/sbin",
    ))
));
$process->run(function ($type, $buffer) use (&$process) {
    if ($process::OUT === $type) {
        $this->info($buffer);
    } else {
        $this->error($buffer);
    }
});