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: 8 months ago
Size: 564 bytes


Class file image Download

use Mateodioev\PhpEasyCli\{App, Color};

__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?: ');
display(Color::Fg(82, 'Hello ' . $name));
$app->run($argv, 'help', function () use ($app) {
$app->getPrinter()->display('Example of callback function when command not found');