PHP Classes

PHP CLI: Process console parameters with callback functions

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 48 All time: 10,742 This week: 57Up
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: 23 packages by
Country: Peru Peru
Age: ???
All time rank: 20464 in Peru Peru
Week rank: 15 Up1 in Peru Peru Up
Innovation award
Innovation award
Nominee: 10x

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 (7)  
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 (7)  /  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

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:48
This week:0
All time:10,742
This week:57Up