PHP Classes

PHP CLI: Process console parameters with callback functions

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 47 All time: 10,704 This week: 571Up
Version License PHP version Categories
php-cli 1.0MIT/X Consortium ...5PHP 5, Console
Description 

Author

This package can process console parameters with callback functions.

It can register callback functions associated with names of parameters that can be passed to the current PHP script when run from the command line console shell.

The package can process the parameters and invoke the callback function associated with the parameter value passed to the current script.

It also provides classes that can output colored text to the console terminal and read data from the standard input.

Picture of Mateo
  Performance   Level  
Name: Mateo <contact>
Classes: 21 packages by
Country: Peru Peru
Age: ???
All time rank: 21074 in Peru Peru
Week rank: 8 Up1 in Peru Peru Up
Innovation award
Innovation award
Nominee: 9x

Winner: 3x

Example

<?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');
});


Details

Cli apps

Installation

composer require mateodioev/php-easy-cli

Usage

$app = new \Mateodioev\PhpEasyCli\App();

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

$app->run($argv, 'help');

  Files folder image Files  
File Role Description
Files folder imagesrc (3 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file readme.MD Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file App.php Class Class source
  Plain text file Color.php Class Class source
  Plain text file Printer.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:47
This week:0
All time:10,704
This week:571Up