1. Go to this page and download the library: Download initphp/console 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/ */
use InitPHP\Console\{Command, Input, InputArgument, Output};
class GreetCommand extends Command
{
public $command = 'app:greet';
public function definition(): string
{
return 'Greets a person.';
}
public function help(): string
{
return 'Prints a friendly greeting to the given name.';
}
public function arguments(): array
{
return [
new InputArgument('name', InputArgument::STR, 'World', true, 'Who to greet.'),
];
}
public function execute(Input $input, Output $output)
{
$output->success('Hi ' . $input->getArgument('name'));
}
}
$console->register(GreetCommand::class);