Skip to content

Setting up a Minicli app as Composer bin command

If you want to distribute your application with an executable that runs from Composer's bin folder, you can use Minicli as an entry point for that.

In this case, when including the Composer autoload script, you'll need to first check if the application is being called from vendor/bin (as a required dependency) or if it's being called from the application folder itself (as a standalone project).

Update your script to include this check:

Updating your Minicli to handle path changes

if (php_sapi_name() !== 'cli') {

$root_app = dirname(__DIR__);

if (!is_file($root_app . '/vendor/autoload.php')) {
    $root_app = dirname(__DIR__, 4);

require $root_app . '/vendor/autoload.php';

$app = new App();
//code continues...

With your script ready, edit the project's composer.json file to include minicli in your bin section:

  "bin": [

This is an example of a valid composer.json file from a demo package built that way:

  "name": "minicli/advice-slip",
  "description": "Demo - Advice Slip",
  "license": "MIT",
  "homepage": "",
  "keywords": ["cli","command-line", "demo"],
  "require": {
    "minicli/minicli": "^2.0",
    "ext-json": "*"
  "bin": [

If your project is already on Packagist, then you'll need to commit and push your changes to the remote repository so that they are picked up by Packagist. You may need to create a new release of your project in order to deliver the changes to existing users.

For more information on how to create a Composer bin command with Minicli, check this tutorial on