To install the package use the command below
composer require awesome-packages/awesome-cli
Add script in composer.json:
"scripts": {
"awesome-cli": "./vendor/bin/awesome-cli"
}
Create your command class:
<?php
namespace AwesomePackages\AwesomeCliTests\Mock;
use AwesomePackages\AwesomeCli\AwesomeCommand;
final class SayHelloWorldCommand extends AwesomeCommand
{
protected string $group = 'say';
protected string $action = 'hello-world';
protected string $description = 'This is a simple description';
public static function handle(): string
{
return 'Hello World';
}
}
Create commands.php file in src/config folder:
<?php
\AwesomePackages\AwesomeCli\CommandRunner::registerCommand([
\AwesomePackages\AwesomeCliTests\Mock\SayHelloWorldCommand::class,
... // More commands
]);
The folder structure will look like this:
src
|_ commands
|_ SayHelloWorldCommand.php
|_ config
|_ commands.php
Finally, run the command below:
composer awesome-cli say:hello-world
MIT © AwesomeCli