Download the PHP package adhocore/cli without Composer

On this page you can find all versions of the php package adhocore/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cli

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 Tweet Support

Screen Preview

What's included

Core: Shell

IO: Stream reader

Other: Autocompletion

Installation

Usage

Argv parser

Command help

It can be triggered manually with $command->showHelp() or automatic when -h or --help option is passed to $command->parse().

For above example, the output would be: Command Help

Command version

It can be triggered manually with $command->showVersion() or automatic when -V or --version option is passed to $command->parse().

For above example, the output would be:

Console app

Definitely check adhocore/phint - a real world console application made using adhocore/cli.

Here we simulate a git app with limited functionality of add, and checkout. You will see how intuitive, fluent and cheese building a console app is!

Git app

Organized app

Instead of inline commands/actions, we define and add our own commands (having interact() and execute()) to the app:

Grouping commands

Grouped commands are listed together in commands list. Explicit grouping a command is optional. By default if a command name has a colon : then the part before it is taken as a group, else * is taken as a group.

Example: command name app:env has a default group app, command name appenv has group *.

Exception handler

Set a custom exception handler as callback. The callback receives exception & exit code. The callback may rethrow exception or may exit the program or just log exception and do nothing else.

App help

It can be triggered manually with $app->showHelp() or automatic when -h or --help option is passed to $app->parse(). Note If you pass something like ['app', cmd', '-h'] to $app->parse() it will automatically and instantly show you help of that cmd and not the $app.

For above example, the output would be: App Help

App version

Same version number is passed to all attached Commands. So you can trigger version on any of the commands.

Shell

Very thin shell wrapper that provides convenience methods around proc_open().

Basic usage

Advanced usage

Timeout

Cli Interaction

You can perform user interaction like printing colored output, reading user input programatically and moving the cursors around with provided Ahc\Cli\IO\Interactor.

Confirm

Single choice

Multiple choices

Prompt free input

Prompt with validation

Prompt hidden

On windows platform, it may change the fontface which can be fixed.

Interactive Preview

IO Components

The interactor is composed of Ahc\Cli\Input\Reader and Ahc\Cli\Output\Writer while the Writer itself is composed of Ahc\Cli\Output\Color. All these components can be used standalone.

Color

Color looks cool!

Simple usage

Custom style

Cursor

Move cursor around, erase line up or down, clear screen.

Progress Bar

Easily add a progress bar to your output:

You can also manually advance the bar:

You can override the progress bar options to customize it to your liking:

Writer

Write anything in style.

Output formatting

You can call methods composed of any combinations: '<colorName>', 'bold', 'bg', 'fg', 'warn', 'info', 'error', 'ok', 'comment' ... in any order (eg: bgRedFgBlaock, boldRed, greenBold, commentBgPurple and so on ...)

Free style

Many colors with one single call: wrap text with tags <method> and </end> For NL/EOL just use <eol> or </eol> or <eol/>.

Great for writing long colorful texts for example command usage info.

Raw output

Tables

Just pass array of assoc arrays. The keys of first array will be taken as heading. Heading is auto inflected to human readable capitalized words (ucwords).

Gives something like:

Designing table look and feel

Just pass 2nd param $styles:

Justify content (Display setting)

If you want to display certain configurations (from your .env file for example) a bit like Laravel does (via the php artisan about command) you can use the justify method.

Gives something like:

You can use the sep parameter to define the separator to use.

Gives something like:

In addition, the text color, the background color and the thickness of the two texts can be defined via the 3rd argument of this method.

For more details regarding the different color options, see Custom style

Reader

Read and pre process user input.

Exceptions

Whenever an exception is caught by Application::handle(), it will show a beautiful stack trace and exit with non 0 status code.

Exception Preview

Autocompletion

Any console applications that are built on top of adhocore/cli can entertain autocomplete of commands and options in zsh shell with oh-my-zsh.

All you have to do is add one line to the end of ~/.oh-my-zsh/custom/plugins/ahccli/ahccli.plugin.zsh:

compdef _ahccli <appname>

Example: compdef _ahccli phint for phint.

That is cumbersome to perform manually, here's a complete command you can copy/paste/run:

One time setup

Load ahccli plugin

This is also one time setup.

Registering app

Of course you can add multiple apps, just change appname in above command

Then either restart the shell or source the plugin like so:

Trigger autocomplete

Related

Contributors

License

© 2017-2020, Jitendra Adhikari | MIT

Credits

This project is release managed by please.


All versions of cli with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package adhocore/cli contains the following files

Loading the files please wait ....