PHP Classes

How to Create A PHP Command Line Application with the PackageEasyCLI: Create CLI applications using handler functions

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-05-02 (3 months ago) RSS 2.0 feedNot enough user ratingsTotal: 4 This week: 1All time: 11,423 This week: 59Up
Version License PHP version Categories
easy-cli 1.0.0Custom (specified...8Console, Traits, PHP 8
Description 

Author

This package can create CLI applications using handler functions.

It provides an application class that processes the parameters passed to the PHP CLI as text parameters from the console.

The package also provides command classes that store the values of parameters passed from the console defined by the developer.

The application class will invoke the callback functions after it processes the parameters passed from the console.

Picture of Andrey Postal
  Performance   Level  
Name: Andrey Postal <contact>
Classes: 2 packages by
Country: Brazil Brazil

Documentation

Progress Bar Gif

Easy CLI for PHP

A simple and easy to use library with no dependencies for creating pretty and organized CLI apps in PHP.

Probably I should have thought of a name for it.

Installation

composer require andreypostal/cli

Basic Usage

$app = new App(
    appName: 'MyApp',
    description: 'My app has a cool description',
    cmd: 'php cmd',
    params: [],
    commands: [
        new Command(
            key: 'run',
            description: 'This action will run soon',
            service: [
                'handler' => static function(Context $context): void {
                    App::console('It is so easy!!!');
                },
            ],
        ),
    ],
);
$app->run($argv);

Docs

Examples

About

Author

Andrey Postal - <andreypostal@gmail.com> <br />

License

CLI is licensed under the Apache License 2.0 - see the LICENSE file for details

Acknowledgements

Highly inspired by the Go library urfave/cli


  Files folder image Files (34)  
File Role Description
Files folder imageassets (5 files)
Files folder imagedoc (3 files)
Files folder imageexamples (7 directories)
Files folder imagesrc (1 file, 4 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (34)  /  assets  
File Role Description
  Accessible without login Image file centralized.jpg Icon Icon image
  Accessible without login Image file help.jpg Icon Icon image
  Accessible without login Image file initial.gif Data Auxiliary data
  Accessible without login Image file progress-bar.png Data Auxiliary data
  Accessible without login Image file progress-bars.gif Data Auxiliary data

  Files folder image Files (34)  /  doc  
File Role Description
  Accessible without login Plain text file 01-usage.md Data Auxiliary data
  Accessible without login Plain text file 02-utilities.md Data Auxiliary data
  Accessible without login Plain text file 03-components.md Data Auxiliary data

  Files folder image Files (34)  /  examples  
File Role Description
Files folder imageBasicHandler (1 file)
Files folder imageBasicService (2 files)
Files folder imageBooleanFlag (2 files)
Files folder imageComplete (3 files)
Files folder imageInfiniteProgressBar (2 files)
Files folder imageParamsValidation (2 files)
Files folder imageProgressBar (2 files)

  Files folder image Files (34)  /  examples  /  BasicHandler  
File Role Description
  Accessible without login Plain text file cmd Example Example script

  Files folder image Files (34)  /  examples  /  BasicService  
File Role Description
  Plain text file cmd Class Class source
  Plain text file Service.php Class Class source

  Files folder image Files (34)  /  examples  /  BooleanFlag  
File Role Description
  Plain text file cmd Class Class source
  Plain text file Service.php Class Class source

  Files folder image Files (34)  /  examples  /  Complete  
File Role Description
  Accessible without login Plain text file app Example Example script
  Plain text file MyCommand.php Class Class source
  Plain text file MyService.php Class Class source

  Files folder image Files (34)  /  examples  /  InfiniteProgressBar  
File Role Description
  Plain text file cmd Class Class source
  Plain text file Service.php Class Class source

  Files folder image Files (34)  /  examples  /  ParamsValidation  
File Role Description
  Plain text file cmd Class Class source
  Plain text file Service.php Class Class source

  Files folder image Files (34)  /  examples  /  ProgressBar  
File Role Description
  Plain text file cmd Class Class source
  Plain text file Service.php Class Class source

  Files folder image Files (34)  /  src  
File Role Description
Files folder imageComponents (2 files)
Files folder imageExceptions (1 file)
Files folder imageTypes (4 files)
Files folder imageUtils (1 file)
  Plain text file App.php Class Class source

  Files folder image Files (34)  /  src  /  Components  
File Role Description
  Plain text file InfiniteProgressBar.php Class Class source
  Plain text file ProgressBar.php Class Class source

  Files folder image Files (34)  /  src  /  Exceptions  
File Role Description
  Plain text file CliException.php Class Class source

  Files folder image Files (34)  /  src  /  Types  
File Role Description
  Plain text file Command.php Class Class source
  Accessible without login Plain text file ConsoleLevel.php Aux. Auxiliary script
  Plain text file Context.php Class Class source
  Plain text file Param.php Class Class source

  Files folder image Files (34)  /  src  /  Utils  
File Role Description
  Plain text file Output.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:4
This week:1
All time:11,423
This week:59Up