Minicli is a minimalist, zero-dependency framework for building CLI-centric PHP applications. It provides a structured way to organize your commands, as well as various helpers to facilitate working with command arguments, obtaining input from users, and printing colored output to the terminal. Since version 3.0, Minicli requires PHP 8.
- PHP >= 8.0
ext-readlineto obtain user input
Apart from that, you'll need Composer to install and use Minicli.
Minicli is committed to creating a safer software supply chain ecosystem, that's why we don't bring any chained dependencies with the base
minicli/minicli package. Starting from version
3.2.0, we also include SBOM files with every release of Minicli. You can download here our latest SBOM in SPDX format.
minicli/minicli package contains everything you need to create a simple command-line PHP application to consume an API, generate some data, or just playing around with the command line in PHP-land.
You can always opt to bootstrap your application with the
minicli/application template repository, and you are encouraged to share and reuse Minicli commands, but we believe that it should be completely up to you which packages you want your application to depend on.
minicli/minicli package has only testing dependencies; these are only installed when you clone Minicli for development.
The minicli/application project template contains the skeleton of a more structured application including tests bootstrapped with PestPHP and a couple official Minicli commands such as the default help command.
For a dependency-free experience, you must require
minicli/minicli from an existing project, and you'll have the freedom to create your own app structure.
There are mainly two ways to get started: you can choose to create a project from scratch, which might be a good choice for single command apps or to integrate your command / app within another system, or you can use our application repository template, which sets up a minimal structure with Command Namespaces and Controllers - this is the recommended way if you're creating a new standalone command-line application with Minicli.
Both methods are explained in detail in the Getting Started Guide.
The following example shows a simple application with a single command registered as callback under the name
test. The command prints output in different colors:
You can run the registered command with:
./minicli test. The output looks like the following:
We welcome all types of contributions and contributors to Minicli and its adjacent repositories, as long as you stick to our code of conduct and follow our simple contributing guidelines. The TL;DR is:
- be excellent to each other
- feel free to ask all the questions
- keep simplicity always in mind
- discuss ideas before implementing something big
- follow the PSR-12 PHP code standards if you are contributing with code
Minicli was initially created as an experiment about going dependency-free in the context of PHP. The following tutorials on dev.to compose a series named "Building Minicli", where we created the first version of
minicli from scratch:
- Part 1: Bootstrapping a CLI PHP Application in Vanilla PHP [ minicli v.0.1.0 ]
- Part 2: Building minicli: Implementing Command Controllers [ minicli v.0.1.2 ]
- Part 3: Building minicli: Autoloading Command Namespaces [ minicli v.0.1.3 ]
- Part 4: Introducing minicli: a microframework for CLI-centric PHP applications
Minicli has evolved a lot since that series was initially written, with the help of many contributors. Thank you!
Created with Minicli¶
The following applications were created using Minicli: