A component to create easily extendible and executable CLI scripts. Includes a class to format text as terminal output in a simplified way.
requires PHP ^8.2
Require GSpataro/CLI via composer:
composer require gspataro/cli
use GSpataro\CLI;
// Initialize the commands collection
$commands = new CLI\CommandsCollection();
// Create a command called 'hi' that will print 'hello world' to the console
$commands->create('hi')
->setCallback(fn(CLI\Input $input, CLI\Output $output) => $output->print('Hello world!'));
// Initialize the component by providing a collection of commands
$handler = new CLI\Handler($commands);
$handler->deploy();
If you want to learn more about this component's features please read the WIKI.
If you want to contribute to this repository please follow the guidelines here: CONTRIBUTING.md
Consider also following me on twitter: @gspataro96
To see all the latest changes see the CHANGELOG.
The GSpataro/CLI component is licensed under the MIT License.