Docs

Cli

A single executable—vendor/bin/ml—that wraps every developer & ops workflow into one cohesive UX:

Area

Commands (high-level)

Project scaffolding

make:controller, make:middleware, make:entity, make:policy, make:seeder

Database

migrate, migrate:rollback, db:migrate (runs + logs), db:seed

Security

auth:keygen, auth:hash

Maintenance

cache:clear, view:clear, route:list, config:cache

All commands extend Symfony Console’s Command class but have zero direct dependency on the Symfony package—MonkeysLegion ships its own 2-file micro framework with the same signature.

1 · Installation

composer require monkeyscloud/monkeyslegion-cli

The binary registers via Composer’s bin section, so ml is immediately runnable inside ./vendor/bin/.

2 · Global Options

php vendor/bin/ml [command] [--env=prod] [-q|--quiet] [-vvv|--verbose] [--no-ansi]
  • --env switches config context (dev default).

  • --verbose maps to Monolog levels for unified logging.

  • All core commands honour these flags.

3 · Command Reference

Command

Purpose

Core Class

cache:clear

Remove runtime & view caches

ClearCacheCommand

migrate

Apply pending DB migrations

MigrateCommand

db:migrate

Alias for migrate (for muscle memory)

 

migrate:rollback

Roll back last batch

DatabaseMigrationCommand

auth:keygen

Generate RSA keypair for JWT

KeyGenerateCommand

make:controller

Scaffold HTTP controller w/ route attributes

MakeControllerCommand

make:middleware

Scaffold PSR-15 middleware class

MakeMiddlewareCommand

make:entity

Generate an Entity + repository skeleton

MakeEntityCommand

make:policy

Create a Policy class stub

MakePolicyCommand

make:seeder

Boilerplate DB seeder

MakeSeederCommand

Scaffolders lean on MakerHelpers for PSR-4 path guessing & namespace generation.

4 · Usage Examples

4.1 Create a Controller

php vendor/bin/ml make:controller PostController
# → src/Http/Controller/PostController.php

The file contains a ready-to-go class with an example index() route attribute.

4.2 Run Migrations

php vendor/bin/ml migrate        # apply new migrations
php vendor/bin/ml migrate -vvv   # verbose SQL output
php vendor/bin/ml migrate:rollback

4.3 Clear Cached Views & Config

php vendor/bin/ml cache:clear

5 · Adding Custom Commands

use MonkeysLegion\Cli\Command;

final class SayHelloCommand extends Command
{
    protected string $signature = 'hello {name?}';
    protected string $description = 'Greets a user';

    public function handle(): int
    {
        $this->info('Hello ' . ($this->argument('name') ?? 'world') . '!');
        return 0;
    }
}

Register in your DI bootstrap:

return [
    Command::class => [
        SayHelloCommand::class,
        // …core commands auto-loaded
    ],
];

6 · Shell Completion (bash/zsh/fish)

# generate once, then source in .zshrc or .bashrc
php vendor/bin/ml completion --shell=zsh > ~/.monkeyslegion_zsh

7 · Testing

Commands are plain PHP objects; call handle() directly or use PHPUnit’s expectOutputString():

$cmd = new SayHelloCommand();
$cmd->setLaravel(app());   // optional DI container
$tester = new CommandTester($cmd);

$tester->execute(['name' => 'Alice']);
$this->assertEquals("Hello Alice!\n", $tester->getDisplay());

License

MIT © 2025 MonkeysCloud