PHP execute shell commands with exec

PHP exec command is used to execute system commands.

I wanted to run “composer install” on a server with out SSH access. I created following script, uploaded to server.

<?php

$cmd = "composer install";

$result = exec("$cmd 2>&1", $result2);

echo "<pre>";

print_r($result);
print_r($result2);

Posted in PHP