Download the PHP package innmind/cli without Composer

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

CLI

Build Status codecov Type Coverage

CLI is a small library to wrap all the needed informations to build a command line tool. The idea to build this came while reading the ponylang documentation realising that other languages use a similar approach for the entry point of the app, so I decided to have something similar for PHP.

The said approach is to have a main function as the starting point of execution of your code. This function has a the environment it runs in passed as argument so there's no need for global variables. However since not everything can be passed down as argument (it would complicate the interface), ambient authority can be exercised (as in regular PHP script).

Important: to correctly use this library you must validate your code with vimeo/psalm

Installation

Usage

To start a new CLI tool you need this boilerplate code:

This will directly call the main function. The $env variable gives you access to the 3 standard streams (stdin, stdout, stderr), the list of arguments passed in the cli, all the environment variables, the working directory, if the terminal is interactive and a method to specify the exit code.

Note: Calling $env->exit(1) will not exit directly your program, you must call return $env->exit(1); in order to make the main function to stop.

Commands

Using directly the main function is enough when building simple tools, but you often want to provide multiple commands in the same tool (associated with arguments/options validation). This library provides a way to do that. Here's an example:

In your terminal you would call this command like this php cli.php foo. But since here a single command is defined you could simply call php cli.php. Of course you can define as many commands as you wish.

Here the command is an anonymous class to simplify the example, but it can be a normal class implementing Command. Since the command simply needs to implement an interface, you have full control of the dependencies you can inject into it. Meaning your commands instances can comme from a dependency injection container. The other advantage since the interface is simple is that you can easily unit test your commands.

The Command interface requires you to implement 2 methods: __invoke and usage. The first one is the one that will be called if it's the desired command to be called. usage is the place where you define the structure of your command, by that I mean the name of the command, the list of its arguments/options, its short description and full description.

To define all properties of your command it would ressemble to this:

Command name and short description are displayed when you run the help command (that will list all available commands). The list of arguments/options and full description are displayed only when you call the command with the extra --help option (or you misused the command).

To define arguments you have access to 3 patterns:

To define options you have access to 2 patterns:


All versions of cli with dependencies

PHP Build Version
Package Version
Requires php Version ~8.2
innmind/stream Version ~4.0
innmind/immutable Version ~4.15|~5.0
innmind/url Version ~4.0
innmind/operating-system Version ~4.0|~5.0
innmind/stack-trace Version ~4.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 innmind/cli contains the following files

Loading the files please wait ....