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. [Database &amp; ORM](/categories/database)
4. /
5. monkeyscloud/monkeyslegion-cli

ActiveLibrary[Database &amp; ORM](/categories/database)

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

Full-featured CLI framework for MonkeysLegion — code generation, migrations, environment tools, and interactive developer console.

2.0.10(1w ago)12.3k↓31%[1 PRs](https://github.com/MonkeysCloud/MonkeysLegion-Cli/pulls)15MITPHPPHP ^8.4

Since Jul 24Pushed 1w 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 yesterday

READMEChangelogDependencies (34)Versions (34)Used By (15)

MonkeysLegion CLI v2
====================

[](#monkeyslegion-cli-v2)

> Attribute-driven, PHP 8.4+ command-line toolkit for the MonkeysLegion framework.

[![PHP Version](https://camo.githubusercontent.com/6e44ad49e5307c87d1393389feb52ab61c99956e2e5f8c77177b2501f1d3d47f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d3838393242462e737667)](https://php.net)[![License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)[![Tests](https://camo.githubusercontent.com/788cfbacb02332826460b2db531fbc056dd634ea9742c0ca361c58ea837abe3a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d31353225323070617373696e672d73756363657373)](phpunit.xml.dist)

---

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Quick Start](#quick-start)
- [Architecture](#architecture)
- [Command Reference](#command-reference)
- [Entity Generator](#entity-generator)
- [Migration System](#migration-system)
- [Maker Commands](#maker-commands)
- [Writing Custom Commands](#writing-custom-commands)
- [Console Output API](#console-output-api)
- [Testing](#testing)
- [Contributing](#contributing)

---

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

[](#installation)

```
composer require monkeyscloud/monkeyslegion-cli:^2.0
```

**Requirements:** PHP 8.4+, `nikic/php-parser` (for entity AST manipulation).

---

Quick Start
-----------

[](#quick-start)

```
# List all commands
php ml list

# Filter by prefix
php ml make:

# Generate an entity interactively
php ml make:entity User

# Generate an entity non-interactively (CI mode)
php ml make:entity Product --fields="name:string,price:decimal:nullable,sku:string"

# Run migrations
php ml migrate
```

---

Architecture
------------

[](#architecture)

### v2 Design Principles

[](#v2-design-principles)

1. **Attribute-driven** — Commands register via `#[Command('name', 'description')]` attributes
2. **PHP 8.4+** — Leverages asymmetric visibility (`public private(set)`), property hooks, `readonly` classes
3. **Zero boilerplate** — Entity properties are public (no getter/setter generation); only collection relations get add/remove/get helpers
4. **Dual mode** — Every generator supports both interactive wizard and `--flags` non-interactive usage
5. **PSR-4 split** — Each enum/class lives in its own file for proper autoloading

### Directory Structure

[](#directory-structure)

```
src/
├── CliKernel.php              # Attribute-driven kernel with auto-discovery
├── Command/                   # 39 built-in commands
│   ├── MakerHelpers.php       # Shared trait for make:* commands
│   ├── MakeEntityCommand.php  # Interactive entity wizard
│   ├── MigrateCommand.php     # Migration runner
│   └── ...
├── Config/                    # Configuration value objects
│   ├── EntityConfig.php       # Aggregate config for entity wizard
│   ├── FieldType.php          # Database field type enum (36 types)
│   ├── FieldTypeConfig.php    # Field type resolver
│   ├── PhpTypeMap.php         # DB type → PHP type mapping
│   ├── RelationKind.php       # Relation kind enum (4 kinds)
│   ├── RelationKeywordMap.php # Relation attribute names
│   └── RelationInverseMap.php # Inverse relation resolver
├── Console/                   # Console abstractions
│   ├── Attributes/Command.php # #[Command] attribute class
│   ├── Command.php            # Base command with 20+ helpers
│   ├── Output/
│   │   ├── TableRenderer.php  # UTF-8 box-drawing tables
│   │   ├── ProgressBar.php    # Progress bar with ETA
│   │   └── Spinner.php        # Braille animation spinner
│   └── Traits/Cli.php         # Colored output builder (CliLineBuilder)
├── Helpers/
│   └── Identifier.php         # PHP identifier validator
├── Service/
│   └── ClassManipulator.php   # PhpParser-based AST entity editor
└── Support/
    └── CommandFinder.php      # Auto-discovery via Composer PSR-4

```

---

Command Reference
-----------------

[](#command-reference)

### General

[](#general)

CommandDescription`list` / `help`Display all available commands`about`Framework, PHP, and environment information`down`Put application in maintenance mode`up`Bring application out of maintenance mode`tinker`Interactive REPL with DI container`optimize`Run config:cache + route:cache + clear old caches### Database (`db:`)

[](#database-db)

CommandDescription`db:create`Create the database schema from .env credentials`db:seed`Run database seeders (optionally specify one)`db:wipe`Drop all tables in the database### Cache (`cache:` / `config:`)

[](#cache-cache--config)

CommandDescription`cache:clear`Clear the compiled view cache`config:cache`Compile config files into a cached file### Environment (`env:`)

[](#environment-env)

CommandDescription`env:sync`Compare .env with .env.example for missing keys`key:generate`Generate a new APP\_KEY in your .env file### Migration (`migrate:`)

[](#migration-migrate)

CommandAliasesDescription`migrate``m`Run pending database migrations`migrate:rollback``m:rb`Rollback the last migration batch`migrate:fresh`—Drop all tables and re-run all migrations`migrate:refresh`—Rollback all and re-run all migrations`migrate:status``m:st`Show ran and pending migrations`make:migration`—Generate a blank migration file`schema:update`—Compare entities → database and apply changes### Maker (`make:`)

[](#maker-make)

CommandDescription`make:entity`Generate or update an Entity class with fields &amp; relationships`make:controller`Generate a new Controller class`make:middleware`Generate a PSR-15 middleware class`make:service`Generate a service class`make:dto`Generate a readonly DTO class`make:enum`Generate a backed enum class`make:event`Generate a domain event class`make:listener`Generate an event listener class`make:job`Generate a queue job class`make:resource`Generate a JSON:API resource class`make:factory`Generate an entity factory for testing`make:observer`Generate an entity lifecycle observer`make:policy`Generate an authorization policy class`make:seeder`Generate a database seeder class`make:test`Generate a PHPUnit test class`make:command`Generate a custom CLI command### Routing (`route:`)

[](#routing-route)

CommandDescription`route:list`List all registered routes (filter with `--method`, `--path`)`route:cache`Cache all routes for production### API

[](#api)

CommandDescription`openapi:export`Dump OpenAPI spec to stdout or a file---

Entity Generator
----------------

[](#entity-generator)

### Interactive Mode

[](#interactive-mode)

```
php ml make:entity User
```

Launches a wizard that lets you:

1. **Add fields** — Choose from 36 database types with nullable support
2. **Add relationships** — OneToOne, OneToMany, ManyToOne, ManyToMany with automatic inverse generation
3. **Save** — Writes the entity using PhpParser AST manipulation (non-destructive)

### Non-Interactive Mode

[](#non-interactive-mode)

```
php ml make:entity Product --fields="name:string,price:decimal:nullable,sku:string,active:boolean"
```

Parses `field:type[:nullable]` triplets and applies them in a single pass. Ideal for CI pipelines.

### Generated Entity (v2 Style)

[](#generated-entity-v2-style)

```
