1. Go to this page and download the library: Download alesinicio/clicommand 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/ */
alesinicio / clicommand example snippets
//Hello.php
namespace Your\Namespace;
class Hello implements Alesinicio\CLICommand\Commands\CLICommandInterface {
public function run(mixed ...$args) : void {
echo sprintf("Hello %s!\n", $args[0] ?? 'noname');
}
}
//yourDependencyInjectionRegistry.php
$commandCollection = new Alesinicio\CLICommand\CommandCollection();
$commandCollection
->addCommand('hello', Your\Namespace\Hello::class)
;
//command.php
global $argc, $argv;
$di = loadYourDependencyInjectionContainer();
try {
$di->get(Alesinicio\CLICommand\CLICommandHandler::class))->handle($argc, $argv);
} catch (Exception $e) {}