PHP code example of globaltriangles / shell-commander
1. Go to this page and download the library: Download globaltriangles/shell-commander library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
globaltriangles / shell-commander example snippets
use ShellCommander\Commander;
//the string of the command to execute is this case a simple ls
$command = 'ls';
//Call the static method an Execute the command saving the outputs to a variable
$exec = Commander::exec($command);
if(! empty($exec['output'])) {
//Do Something with the output string like so...
echo $exec['output'];
}
if(! empty($exec['error'])) {
//Do Something with the error string like so...
echo $exec['error'];
}