1. Go to this page and download the library: Download nixphp/cli 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/ */
nixphp / cli example snippets
namespace App\Commands;
use NixPHP\CLI\Core\AbstractCommand;
use NixPHP\CLI\Core\Input;
use NixPHP\CLI\Core\Output;
class HelloCommand extends AbstractCommand
{
public const NAME = 'hello:say';
protected function configure(): void
{
$this->setTitle('Say Hello');
$this->addArgument('name');
}
public function run(Input $input, Output $output): int
{
$name = $input->getArgument('name');
$output->writeLine("Hello, {$name}!", 'ok');
return static::SUCCESS;
}
}