PHPackages                             monkeyscloud/monkeyslegion-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. monkeyscloud/monkeyslegion-cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

monkeyscloud/monkeyslegion-cli
==============================

Command-line interface and developer tooling for the MonkeysLegion framework.

1.0.14(2mo ago)11.3k↑142.9%[1 PRs](https://github.com/MonkeysCloud/MonkeysLegion-Cli/pulls)9MITPHPPHP ^8.4

Since Jul 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MonkeysCloud/MonkeysLegion-Cli)[ Packagist](https://packagist.org/packages/monkeyscloud/monkeyslegion-cli)[ RSS](/packages/monkeyscloud-monkeyslegion-cli/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (20)Used By (9)

MonkeysLegion CLI
=================

[](#monkeyslegion-cli)

Developer tooling and command-line entrypoint for MonkeysLegion applications. The package bundles the `ml` executable, a reflection-driven `CliKernel`, and a base `Command` class for building rich, colored console commands.

Requirements
------------

[](#requirements)

- PHP ^8.4
- MonkeysLegion core packages (installed via Composer dependencies)
- Access to your application's `config/app.php` and `vendor/autoload.php`

Installation
------------

[](#installation)

Install via Composer inside a MonkeysLegion application or skeleton:

```
composer require monkeyscloud/monkeyslegion-cli
```

Composer will link the executable at `vendor/bin/ml` (or `bin/ml` in the skeleton). Ensure your project configuration lives at `config/app.php` so the CLI can bootstrap the DI container.

Running the CLI
---------------

[](#running-the-cli)

Use the `ml` binary to explore and execute commands:

```
vendor/bin/ml            # prints all commands grouped by prefix
vendor/bin/ml list       # equivalent to the default
vendor/bin/ml db:        # show only commands under the "db" prefix
vendor/bin/ml migrate    # run a specific command
```

The entrypoint climbs parent directories to locate `vendor/autoload.php`, verifies `config/app.php`, builds the application container, and hands execution to the `CliKernel`.【F:bin/ml†L12-L44】

How command discovery works
---------------------------

[](#how-command-discovery-works)

- `CliKernel` accepts an iterable of command classes (typically from `Support\CommandFinder`) and also scans the package's `MonkeysLegion\Cli\Command\*` plus your application's `App\Cli\Command\*` namespace for classes marked with the `#[Command]` attribute.【F:src/CliKernel.php†L14-L128】
- Commands are grouped by prefix (e.g., `db:create`, `make:entity`). Using `list` or a trailing colon (`db:`) prints grouped help with descriptions sourced from the attribute metadata.【F:src/CliKernel.php†L201-L360】
- When a signature is unknown, the kernel suggests similar commands using prefix and Levenshtein matching.【F:src/CliKernel.php†L201-L401】

### CommandFinder

[](#commandfinder)

`MonkeysLegion\Cli\Support\CommandFinder::all()` walks Composer's PSR-4 map to include every `Cli/Command/*.php` file across registered namespaces and yields the classes that extend the base `Command` class.【F:src/Support/CommandFinder.php†L10-L64】 Pass its result into the kernel if you need to control discovery yourself.

Building commands
-----------------

[](#building-commands)

Create commands by extending `MonkeysLegion\Cli\Console\Command` and annotating the class with `#[Command(signature, description)]`. The base class provides helpers for colored output, prompts, argument parsing, and option handling.【F:src/Console/Attributes/Command.php†L9-L19】【F:src/Console/Command.php†L11-L260】

```
