PHPackages                             inanepain/console - 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. inanepain/console

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

inanepain/console
=================

Console routing and argument handling.

0.3.0(4mo ago)12UnlicensePHPPHP &gt;=8.4

Since Dec 5Pushed 1mo agoCompare

[ Source](https://github.com/inanepain/console)[ Packagist](https://packagist.org/packages/inanepain/console)[ Docs](https://git.cathedral.co.za:3000/inanepain/console)[ RSS](/packages/inanepain-console/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

inanepain/console [![icon](./icon.png "inanepain/console")](./icon.png)
=======================================================================

[](#inanepainconsole-)

Table of Contents

- [![icon](./icon.png "inanepain/console") inanepain/console](#inanepainconsole)
- [1. Introduction](#introduction)
    - [1.1. Features](#features)
    - [1.2. Requirements](#requirements)
- [2. Install](#install)
    - [2.1. Basic Setup](#basic-setup)
- [3. Quick Start](#quick-start)
    - [3.1. Your First Command](#your-first-command)
- [4. Core Concepts](#core-concepts)
    - [4.1. Commands](#commands)
        - [4.1.1. Syntax](#syntax)
        - [4.1.2. Parameters](#parameters)
        - [4.1.3. Example](#example)
    - [4.2. Arguments](#arguments)
        - [4.2.1. Syntax](#syntax-1)
        - [4.2.2. Parameters](#parameters-1)
        - [4.2.3. Example](#example-1)
    - [4.3. Options](#options)
        - [4.3.1. Syntax](#syntax-2)
        - [4.3.2. Parameters](#parameters-2)
        - [4.3.3. Option Types](#option-types)
- [5. Advanced Usage](#advanced-usage)
    - [5.1. Command Namespacing](#command-namespacing)
    - [5.2. Multiple Controllers](#multiple-controllers)
    - [5.3. Exit Codes](#exit-codes)
    - [5.4. Variadic argument Example](#variadic-argument-example)
    - [5.5. Complex Example](#complex-example)
- [6. Help System](#help-system)
    - [6.1. Viewing Help](#viewing-help)
        - [6.1.1. List All Commands](#list-all-commands)
        - [6.1.2. Command-Specific Help](#command-specific-help)
    - [6.2. Version Information](#version-information)
- [7. Best Practices](#best-practices)
    - [7.1. Command Design](#command-design)
    - [7.2. Error Handling](#error-handling)
    - [7.3. User Feedback](#user-feedback)
- [8. API Reference](#api-reference)
    - [8.1. ConsoleRouter Class](#consolerouter-class)
        - [8.1.1. Methods](#methods)
- [9. Troubleshooting](#troubleshooting)
    - [9.1. Common Issues](#common-issues)
        - [9.1.1. "Command not found"](#command-not-found)
        - [9.1.2. "Required argument missing"](#required-argument-missing)
        - [9.1.3. Colors not showing](#colors-not-showing)
- [10. Examples Repository](#examples-repository)
    - [10.1. Task Management CLI](#task-management-cli)

[![icon](./icon.png "inanepain/console")](./icon.png) inanepain/console
-----------------------------------------------------------------------

[](#-inanepainconsole)

Console routing and argument handling.

1. Introduction
---------------

[](#1-introduction)

The PHP Console Router is a modern, attribute-based command-line application framework for PHP 8+. It provides an elegant way to define CLI commands using PHP attributes, automatic argument parsing, and beautiful help documentation.

### 1.1. Features

[](#11-features)

- ✅ Attribute-based command definition
- ✅ Automatic argument and option parsing
- ✅ Short and long option formats (`-f`, `--force`)
- ✅ Required and optional arguments
- ✅ Default values for parameters
- ✅ Command aliases
- ✅ Automatic help generation
- ✅ Color-coded terminal output
- ✅ Command grouping by namespace

### 1.2. Requirements

[](#12-requirements)

- PHP 8.0 or higher
- CLI SAPI (command-line interface)

2. Install
----------

[](#2-install)

composer

```
composer require inanepain/console
```

### 2.1. Basic Setup

[](#21-basic-setup)

Create your project structure:

```
project/
├── console.php
├── src/
│   ├── AppCommands.php
```

Create your `console.php` bootstrap file:

```
