PHP code example of gspataro / cli

1. Go to this page and download the library: Download gspataro/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/ */

    

gspataro / cli example snippets


use GSpataro\CLI;

// Initialize the commands collection
$commands = new CLI\CommandsCollection();

// Create a command called 'hi' that will print 'hello world' to the console
$commands->create('hi')
    ->setCallback(fn(CLI\Input $input, CLI\Output $output) => $output->print('Hello world!'));

// Initialize the component by providing a collection of commands
$handler = new CLI\Handler($commands);
$handler->deploy();