1. Go to this page and download the library: Download kamermans/command 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/ */
use kamermans\Command\Command;
$cmd = Command::factory('ls')
->setCallback(function($pipe, $data) {
// Gets run for every 4096 bytes
echo $data;
})
->setReadBuffer(4096)
->setDirectory('/tmp')
->option('-l')
->run();
use kamermans\Command\Command;
$cmd = Command::factory('ls')
->setCallback(function($pipe, $data){
// Gets run for each line of output
echo $data;
})
->setDirectory('/tmp')
->option('-l')
->run(null, true);
use kamermans\Command\Command;
E.md';
$stdin = fopen($filename, 'r');
// This will read README.md and grep for lines containing 'the'
$cmd = Command::factory("grep 'the'")
->setCallback(function($pipe, $data) {
// Change the text to uppercase
$data = strtoupper($data);
if ($pipe === Command::STDERR) {
Command::echoStdErr($data);
} else {
echo $data;
}
})
->run($stdin);
fclose($stdin);
use kamermans\Command\Command;
$stdin = "banana
orange
apple
pear
";
$cmd = Command::factory("sort")
->run($stdin);
echo $cmd->getStdOut();
use kamermans\Command\Command;
$filename = __DIR__.'/../README.md';
$stdin = fopen($filename, 'r');
// This will count the number of words in the README.md file
$cmd = Command::factory("wc")
->option("--words")
->run($stdin);
fclose($stdin);
$words = trim($cmd->getStdOut());
echo "File $filename contains $words words\n";
use kamermans\Command\Command;
echo "Type some words, one per line, then press CTRL-D and they will be sorted:\n";
$cmd = Command::factory("sort")
// This causes Command to use the real STDIN
->run(STDIN);
echo "\n";
echo $cmd->getStdOut();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.