Download the PHP package jbzoo/cli without Composer

On this page you can find all versions of the php package jbzoo/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

JBZoo / Cli

CI Coverage Status Psalm Coverage Psalm Level CodeFactor
Stable Version Total Downloads Dependents GitHub License

Why?

The library greatly extends the functionality of CLI App and helps make creating new console utilities in PHP quicker and easier. Here's a summary of why this library is essential:

Live Demo

Output regular messages

asciicast

Progress Bar Demo

asciicast

Quck Start - Build your first CLI App

Installing

The simplest CLI application has the following file structure. See the Demo App for more details.

File Structure

Composer file

./demo/composer.json

See Details

Binary file

Binary file: demo/my-app

See Details

Simple CLI Action

The simplest CLI action: ./demo/Commands/DemoSimple.php

See Details

Built-in Functionality

Sanitize input variables

As live-demo take a look at demo application - ./demo/Commands/DemoOptionsStrictTypes.php.

Try to launch ./my-app options-strict-types.

Rendering text in different colors and styles

There are list of predefined colors

There are list of predefined styles

Also, you can combine colors ans styles.

And predefined shortcuts for standard styles of Symfony Console

Verbosity Levels

Console commands have different verbosity levels, which determine the messages displayed in their output.

As live-demo take a look at demo application - Demo video.

Example of usage of verbosity levels

Memory and time profiling

As live-demo take a look at demo application - ./demo/Commands/DemoProfile.php.

Try to launch ./my-app profile --profile.

Progress Bar

As live-demo take a look at demo application - Live Demo.

You can consider this as a substitute for the long cycles you want to profile.

Keep in mind that there is an additional overhead for memory and runtime to calculate all the extra debugging information in --verbose mode.

Simple example

Advanced usage

Helper Functions

As live-demo take a look at demo application - ./demo/Commands/DemoHelpers.php.

Try to launch ./my-app helpers.

JBZoo/Cli uses Symfony Question Helper as base for aliases.

Regualar question

Ask any custom question and wait for a user's input. There is an option to set a default value.

Ask user's password

Ask a question and hide the response. This is particularly convenient for passwords. There is an option to set a random value as default value.

Ask user to select the option

If you have a predefined set of answers the user can choose from, you could use a method askOption which makes sure that the user can only enter a valid string from a predefined list. There is an option to set a default option (index or string).

Represent a yes/no question

Suppose you want to confirm an action before actually executing it. Add the following to your command.

Rendering key=>value list

If you need to show an aligned list, use the following code.

Easy logging

Simple log

Crontab

Just add the --output-mode=cron flag and save the output to a file. Especially, this is very handy for saving logs for Crontab.

Elatcisearch / Logstash (ELK)

Just add the --output-mode=logstash flag and save the output to a file. Especially, this is very handy for saving logs for ELK Stack.

Multi processing

There is a multiprocess mode (please don't confuse it with multithreading) to speed up work with a monotonous dataset. Basically, JBZoo\Cli will start a separate child process (not a thread!) for each dataset and wait for all of them to execute (like a Promise). This is how you get acceleration, which will depend on the power of your server and the data processing algorithm.

You will see a simple progress bar, but you won't be able to profile and log nicely, as it works for normal mode.

You can find examples here

Notes:

Tips & Tricks

Contributing

Useful projects and links

License

MIT

See Also


All versions of cli with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
jbzoo/utils Version ^7.1
jbzoo/event Version ^7.0
symfony/process Version >=6.4
symfony/console Version >=6.4
symfony/lock Version >=6.4
bluepsyduck/symfony-process-manager Version >=1.3.3
monolog/monolog Version ^3.4
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 jbzoo/cli contains the following files

Loading the files please wait ....