Laravel run composer / git commands within controller
<p>is it possible to run composer or git commands from within a controller in Laravel? Something like that:</p>

<pre><code>class TestController extends Controller
{
    //
    public function shell(Request $request){
        if($request-&gt;isMethod('post')){


            $data['output'] = shell_exec('composer update');
            // or some git commands
            return view('tests.shell', $data);
        } else {
            return view('tests.shell');
        }
    }
}
</code></pre>

<p>If I do it the way shown above, I get no message. I think, the problem is, that these commands have to be run in the projects root directory and not in an subfolder.</p>

<p>And is there a php function to run a complete shell script and not only single commands?</p>

<p>I have tested this:</p>

<pre><code>echo shell_exec('php ' . __DIR__ . '/../shell.php');
// shell.php is in projects root directory
</code></pre>

<p>The script is executed, but not in the root directory. </p>

<p>Thanks!</p>