PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Mateo   PHP CLI   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP CLI
Process console parameters with callback functions
Author: By
Last change:
Date: 2 years ago
Size: 564 bytes
 

Contents

Class file image Download
<?php

use Mateodioev\PhpEasyCli\{App, Color};

require
__DIR__ . '/vendor/autoload.php';

$app = new App();

$app->register('help', function() use ($app) {
   
$app->getPrinter()->display('Default command is help!!');
});

$app->register('name', function() use ($app) {
   
$name = $app->getPrinter()->read('What is your name?: ');
   
$app->getPrinter()->clear()
        ->
display(Color::Fg(82, 'Hello ' . $name));
});
$app->run($argv, 'help', function () use ($app) {
   
$app->getPrinter()->display('Example of callback function when command not found');
});