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

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

rokke/console
=============

Console transport adapter for the Rokke Runtime — routes CLI commands to compiled operations

0.1.1(4d ago)00MITPHPPHP &gt;=8.4CI passing

Since Jul 7Pushed yesterdayCompare

[ Source](https://github.com/rokke-php/console)[ Packagist](https://packagist.org/packages/rokke/console)[ Docs](https://rokke.dev)[ RSS](/packages/rokke-console/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (6)Versions (6)Used By (0)

rokke/console
=============

[](#rokkeconsole)

[![CI](https://github.com/rokke-php/console/actions/workflows/ci.yml/badge.svg)](https://github.com/rokke-php/console/actions/workflows/ci.yml)[![Latest Version](https://camo.githubusercontent.com/b8252913338cba671b4b9c3224fa7490ee3eaccd801d2147cdfa58d421823006/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f726f6b6b652d7068702f636f6e736f6c653f6c6162656c3d76657273696f6e)](https://github.com/rokke-php/console/releases)[![PHP](https://camo.githubusercontent.com/755ca4b86b940e73511525af12859edb239dd9c424cde1036f789bf4f574c389/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e342d383839326265)](https://www.php.net)[![License](https://camo.githubusercontent.com/ee06ed2959de786b2d2eee08391debf7c55be3ee9d9b6cdfd2ba73441afc63bb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f726f6b6b652d7068702f636f6e736f6c65)](LICENSE)

Console transport adapter for the [Rokke Runtime](https://github.com/rokke-php/runtime) — routes CLI commands to compiled operations exactly as `rokke/http` routes HTTP requests.

What this is
------------

[](#what-this-is)

`rokke/console` is the CLI transport layer for the Rokke Framework. It scans a directory for classes annotated with `#[Command('name')]`, compiles them into a flat `CommandRegistry` at build time, and at runtime parses `argv` tokens into an `OperationContext` that flows through the same `ExecutionEngine` as HTTP operations.

There is no Swoole dependency — `ConsoleHost::run()` uses plain PHP I/O. The build pipeline (`ConsoleKernel`) mirrors `HttpKernel` precisely: capability → model builder pass → descriptor → compiler → artifact → host.

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

[](#installation)

```
composer require rokke/console
```

**Requires:** PHP ≥ 8.4, `rokke/runtime ^0.15.0`

Usage
-----

[](#usage)

### 1. Create a command handler

[](#1-create-a-command-handler)

```
use Rokke\Console\Attribute\Command;
use Rokke\Console\Attribute\Option;

#[Command('users:create')]
final class CreateUserCommand
{
    public function __invoke(
        #[Option] string $name,
        #[Option] int $age = 0,
    ): string {
        return "Created user {$name} (age {$age})";
    }
}
```

### 2. Boot the kernel and run

[](#2-boot-the-kernel-and-run)

```
use Rokke\Console\ConsoleKernel;
use Rokke\Console\ConsoleModule;

(new ConsoleKernel())
    ->register(new ConsoleModule(
        directory: __DIR__ . '/Commands',
        namespace: 'App\\Commands',
    ))
    ->build()
    ->run(); // reads $_SERVER['argv'] automatically
```

### 3. Invoke from the terminal

[](#3-invoke-from-the-terminal)

```
php app users:create --name=Fernando --age=28
# Created user Fernando (age 28)
```

API reference
-------------

[](#api-reference)

### Attributes

[](#attributes)

AttributeTargetPurpose`#[Command('name')]`classMarks an invokable class as a CLI command`#[Option]`parameterResolves a handler parameter from `--key=value` or `--flag``#[Option(short: 'n')]`parameterAlso accepts `-n value` short form### Key classes

[](#key-classes)

ClassPurpose`ConsoleKernel`Build entry point — discovers, compiles, produces `ConsoleHost``ConsoleModule`Module that wires `ConsoleDirectoryDiscoveryProvider` into the graph`ConsoleHost`Runtime entry point — parses argv, dispatches via `ExecutionEngine``CommandRegistry`Compiled artifact — flat map of `name → operationId``ConsoleContextFactory`Parses raw argv tokens into `OperationContext`When to use
-----------

[](#when-to-use)

Use `rokke/console` when you need to route CLI commands through the same compiled operation pipeline as HTTP handlers — sharing middleware, validation, and result plans between HTTP and CLI surfaces.

For one-off scripts with no need for the operation pipeline, use plain PHP directly.

Stability
---------

[](#stability)

`0.x` — API may evolve as the framework matures. No breaking changes within a minor version.

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/55115722?v=4)[Fernando Duarte](/maintainers/ferchd)[@ferchd](https://github.com/ferchd)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

consolephpphp84rokkephpcliconsolerokke

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rokke-console/health.svg)

```
[![Health](https://phpackages.com/badges/rokke-console/health.svg)](https://phpackages.com/packages/rokke-console)
```

###  Alternatives

[nunomaduro/termwind

It's like Tailwind CSS, but for the console.

2.5k271.5M390](/packages/nunomaduro-termwind)[nunomaduro/laravel-console-task

Laravel Console Task is a output method for your Laravel/Laravel Zero commands.

2592.3M13](/packages/nunomaduro-laravel-console-task)[alecrabbit/php-console-spinner

Extremely flexible spinner for \[async\] php cli applications

24038.0k2](/packages/alecrabbit-php-console-spinner)[mehrancodes/laravel-harbor

A CLI tool to Quickly create On-Demand preview environment for your apps.

10097.5k](/packages/mehrancodes-laravel-harbor)[php-school/learn-you-php

An introduction to PHP's core features: i/o, http, arrays, exceptions and so on.

3202.0k](/packages/php-school-learn-you-php)[alecrabbit/php-cli-snake

Lightweight cli spinner with zero dependencies

29216.7k5](/packages/alecrabbit-php-cli-snake)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
