It is a simple helper library that will allow you to write your console/cli application with PHP.
- PHP 7.2 or higher
composer require initphp/console
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use \InitPHP\Console\{Application, Input, Output};
$console = new Application("My Console Application", '1.0');
// Register commands ...
// hello -name=John
$console->register('hello', function (Input $input, Output $output) {
if ($input->hasArgument('name')) {
$output->writeln('Hello {name}', [
'name' => $input->getArgument('name')
]);
} else {
$output->writeln('Hello World!');
}
}, 'Says hello.');
$console->run();
php console.php list
Copyright © 2022 MIT License