1. Go to this page and download the library: Download ordinary/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/ */
ordinary / command example snippets
class MyCommand extends \Ordinary\Command\Command
{
public function run() : int {
// do something
return 0; // int 0-255 exit status
}
public function showHelp() : void {
fwrite($this->stdout(), <<<HELP
My Help Content
HELP);
}
public function beforeExecute() : ?int {
// do stuff before help screen and before run
return null; // return null to continue or int error status for early exit
}
}
#!/usr/bin/env php
## my-cmd.php
use Ordinary\Command\CommandExec;
use Ordinary\Command\Command;
$exec = new CommandExec();
/** @var Command $cmd */
$cmd = new MyCommand();
exit($exec->execute(
$cmd->withArgs($_SERVER['argv'])
->withStreams(STDIN, STDOUT, STDERR)
));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.