initphp / console
It is a simple helper library that will allow you to write your console/cli application with PHP.
2.0
2023-12-16 15:56 UTC
Requires
- php: >=7.2
This package is auto-updated.
Last update: 2024-10-16 17:44:19 UTC
README
It is a simple helper library that will allow you to write your console/cli application with PHP.
Requirements
- PHP 7.2 or higher
Installation
composer require initphp/console
Usage
#!/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
Credits
License
Copyright © 2022 MIT License