is it possible to run composer or git commands from within a controller in Laravel? Something like that:
class TestController extends Controller
{
//
public function shell(Request $request){
if($request->isMethod('post')){
$data['output'] = shell_exec('composer update');
// or some git commands
return view('tests.shell', $data);
} else {
return view('tests.shell');
}
}
}
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.
And is there a php function to run a complete shell script and not only single commands?
I have tested this:
echo shell_exec('php ' . __DIR__ . '/../shell.php');
// shell.php is in projects root directory
The script is executed, but not in the root directory.
Thanks!