DEV Community

Jitendra
Jitendra

Posted on

PHP Console Application made easy

GitHub logo adhocore / php-cli

PHP Console Application made easy- build great console apps with ease. Comes with Zero Dependency and Autocompletion support.

adhocore/cli

Framework agnostic Command Line Interface utilities and helpers for PHP. Build Console App with ease, fun and love.

Latest Version Build Scrutinizer CI Codecov branch StyleCI Software License Donate 15 Donate 25 Donate 50 Tweet

  • Command line application made easy
  • Inspired by nodejs commander (thanks tj)
  • Zero dependency.
  • For PHP7, PHP8 and for good

Screen Preview

What's included

Core: Argv parser · Cli application · Shell

IO: Colorizer · Cursor manipulator · Stream writer · Stream reader

Other: Autocompletion

Installation

# PHP8.0 and above v1.0.0
composer require adhocore/cli:^v1.0.0
# PHP 7.x
composer require adhocore/cli:^v0.9.0
Enter fullscreen mode Exit fullscreen mode

Usage

Argv parser

$command = new Ahc\Cli\Input\Command('rmdir', 'Remove dirs')
$command
    ->version('0.0.1-dev')
    // Arguments are separated by space
    // Format: `<name>` for required, `[name]` for optional
    //  `[name:default]` for default value, `[name...]` for variadic (last argument)
    ->arguments('<dir> [dirs...]')
    // `-h --help`, `-V --version`, `-v --verbosity` options are already added by default.
    // Format: `<name>` for
Enter fullscreen mode Exit fullscreen mode

Helps you build bespoke, interactive console app easy and quick - includes commands, actions, argument parsing, colors, cursors, interaction and all that is required.

inspired by nodejs commander

Installation

composer install adhocore/cli

Top comments (3)

Collapse
 
pkristiancz profile image
Patrik Kristian • Edited

This looks nice... very nice, will use someday ^_^

Collapse
 
adhocore profile image
Jitendra

thanks for good words. would love to hear about what awesome thing you will be making out of it. 😊

Collapse
 
adhocore profile image
Jitendra

Now supports autocomplete (for now in zsh only, but others might be improved)

github.com/adhocore/php-cli#autoco... :)