raxos / terminal
Base classes for custom terminals with command support.
Requires
- php: >=8.5
- ext-mbstring: *
- jetbrains/phpstorm-attributes: ^1.2
- league/climate: ^3.10
- nunomaduro/collision: ^8.9
- raxos/collection: *
- raxos/contract: *
- raxos/error: *
- raxos/foundation: *
Requires (Dev)
- pestphp/pest: ^5.0
Suggests
None
Provides
None
Conflicts
None
- dev-main
- 3.2.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.9.0
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.20
- 1.0.19
- 1.0.18
- 1.0.17
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
This package is auto-updated.
Last update: 2026-10-03 12:06:23 UTC
README
Raxos Terminal
Build command-line applications with command attributes, typed input and console output.
Documentation | Packagist | Raxos
- Named commands with positional arguments and options.
- Generated help, middleware and optional container injection.
- A printer for messages, tables and interactive input.
- Argument parsing that preserves shell token boundaries and the
--separator.
Installation
Requires PHP 8.5 or later. Enable the mbstring PHP extension. Composer checks the remaining package and extension dependencies declared in composer.json.
composer require "raxos/terminal:^3.2"
Usage
<?php declare(strict_types=1); use Raxos\Contract\Terminal\CommandInterface; use Raxos\Contract\Terminal\TerminalInterface; use Raxos\Terminal\Attribute\Argument; use Raxos\Terminal\Attribute\Command; use Raxos\Terminal\Printer; use Raxos\Terminal\Terminal; require __DIR__ . '/vendor/autoload.php'; #[Command(name: 'greet', description: 'Print a greeting.')] final readonly class GreetCommand implements CommandInterface { public function __construct(#[Argument] public string $name = 'World') {} public function execute(TerminalInterface $terminal, Printer $printer): void { $printer->out("Hello {$this->name}"); } } $terminal = new Terminal(); $terminal->register(GreetCommand::class); $terminal->execute();
Save the example as console.php in your application root and run php console.php greet Ada. Run php console.php help to list commands. Declare positional arguments before options. Class or interface constructor dependencies require a container passed to the terminal.
Documentation
Testing
Run this library's Pest suite from the Raxos workspace:
git clone --recurse-submodules https://github.com/basmilius/raxos.git
cd raxos
composer install
vendor/bin/pest --testsuite=terminal
See Testing Raxos for PHP extensions, integration services and coverage commands. The library's Tests workflow also runs in GitHub Actions.
License
MIT. Copyright (c) 2017 - present Bas Milius.