This is a CLI-tool I use to write command line tools using PHP. It's a wrapper for splitbrain/php-cli that adds some tools and improvements I enjoy having, like:
- HTML-like tags for bullets, paragraphs, break-returns, and colorization
- A
log()
method that's more powerful than the built in info, error, etc methods fromsplitbrain/php-cli
- Tools like
has_command()
,get_php_version()
,rid()
(run in directory), etc - Easier ways to run shell commands and extrapolate results including status, output (
array|string
), etc, with or withoutstderr
(seeaubreypwd\PHP_CLI\Command::exec()
)
...and more.
The best way to familiarize yourself with what you can do see:
The both should document and examplify use-cases until I build more tools with it.
composer require aubreypwd/php-cli
To avoid un-explained options from being thrown as \Exception
's run ::run()
with a try/catch
like so:
namespace aubreypwd\My_CLI;
final class Command extends \aubreypwd\PHP_CLI\Command {
...
}
$cli = new \aubreypwd\My_CLI\Command();
try {
$cli->run();
} catch ( \Exception $e ) {
$cli->log( 'error', "{$e->getMessage()}\n" );
}
splitbrain/php-cli
shows an odd message when you try to use an option like --option|-o
that has not been explained.