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

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

krzysztofzylka/console
======================

Console helper library

1.1.0(2mo ago)02.3k↓51.6%3MITPHPPHP &gt;=8.3

Since Dec 10Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/krzysztofzylka/console)[ Packagist](https://packagist.org/packages/krzysztofzylka/console)[ RSS](/packages/krzysztofzylka-console/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (10)DependenciesVersions (12)Used By (3)

krzysztofzylka/console
======================

[](#krzysztofzylkaconsole)

Small PHP console helper library for:

- colored output,
- argument parsing,
- interactive prompts,
- help rendering,
- ASCII table rendering.

Install
-------

[](#install)

```
composer require krzysztofzylka/console
```

Examples
--------

[](#examples)

Ready-to-run examples are available in `example/`:

- `example/print.php`
- `example/form.php`
- `example/help.php`
- `example/table.php`
- `example/args.php`
- `example/progress.php`

Output
------

[](#output)

Preferred API:

```
use Krzysztofzylka\Console\Prints;

Prints::line('Starting job');
Prints::info('Loading configuration');
Prints::success('Done');
Prints::warning('Running in dry-run mode');
Prints::error('Something went wrong');
Prints::section('Deployment', 'Production release');
Prints::bulletList(['Validate config', 'Run sync', 'Send notification']);
Prints::numberedList(['Build', 'Deploy', 'Verify']);
Prints::kv(['env' => 'prod', 'release' => '1.5.0']);
Prints::json(['service' => 'taskello', 'healthy' => true]);
Prints::blankLine();
Prints::write('Progress: 50%');
```

Legacy aliases still work for backward compatibility:

```
Prints::print('value');  // deprecated, use line()
Prints::sprint('value'); // deprecated, use write()
```

Formatter helpers:

- `Prints::section()` / `Prints::formatSection()`
- `Prints::bulletList()` / `Prints::formatBulletList()`
- `Prints::numberedList()` / `Prints::formatNumberedList()`
- `Prints::kv()` / `Prints::formatKv()`
- `Prints::json()` / `Prints::formatJson()`
- `Prints::blankLine()`

Utilities:

- `Prints::terminalWidth()`
- `Prints::fitLineToWidth()`

Arguments
---------

[](#arguments)

`Args::getArgs($argv)` returns a normalized array with script path, positional arguments and parsed options.

Supported forms:

- `--env=prod`
- `--env prod`
- `--force`
- `-project taskello`
- repeated options like `--tag v1 --tag v2`
- `--` to stop option parsing

```
use Krzysztofzylka\Console\Args;

$parsed = Args::getArgs($argv);

/*
[
    'path' => 'bin/app.php',
    'args' => ['sync'],
    'params' => [
        'env' => 'prod',
        'force' => true,
        'tag' => ['v1', 'v2'],
    ],
]
*/
```

Schema-aware parsing:

```
use Krzysztofzylka\Console\Args;

$parsed = Args::parse($argv, [
    'env' => ['type' => 'string', 'default' => 'dev', 'aliases' => ['e']],
    'force' => ['type' => 'bool', 'default' => false],
    'tag' => ['type' => 'string', 'multiple' => true],
    'retries' => ['type' => 'int', 'default' => 0],
]);
```

Forms
-----

[](#forms)

### Input

[](#input)

```
use Krzysztofzylka\Console\Form;

$name = Form::input('Name:');
$environment = Form::input('Environment:', 'prod');
$token = Form::secretInput('Token:', null, true);
```

Parameters for `Form::input()`:

- `$label` - text shown before input
- `$default` - optional default value
- `$trim` - trim input value
- `$required` - keep asking until non-empty value is provided

`Form::secretInput()` works similarly to `input()`, but hides typed characters when the current environment supports it.

### Prompt

[](#prompt)

```
use Krzysztofzylka\Console\Form;

Form::prompt('Continue?');
Form::prompt('Continue?', ' [y/n]', false, true);
```

Parameters for `Form::prompt()`:

- `$label` - question text
- `$append` - suffix shown next to label
- `$exit` - exit the script when the answer is negative
- `$default` - default yes/no answer

Accepted positive answers:

- `y`
- `yes`
- `t`
- `tak`

Accepted negative answers:

- `n`
- `no`
- `nie`

Help generator
--------------

[](#help-generator)

```
use Krzysztofzylka\Console\Generator\Help;

$overview = new Help();
$overview->addHeader('Commands');
$overview->addHelp('serve', 'Serve the application');
$overview->addHelp('cache:clear', 'Clear cache');
$overview->addHelp('routes:list', 'List routes');

echo $overview->renderOverview();
```

Detailed help for a single command:

```
$help = new Help();
$help->setTitle('Sync command');
$help->setDescription('Synchronize local data with a remote source.');
$help->setUsage('php bin/app sync  [--env=prod] [--force]');
$help->addCommand('sync', 'Synchronize local data with a remote source.');
$help->addArgument('workspace', 'Workspace identifier.', true);
$help->addOption('--env', 'Environment name.', false, 'prod', false, ['dev', 'stage', 'prod']);
$help->addOption('--force', 'Run command without confirmation.');
$help->addExample('php bin/app sync main --env=prod', 'Synchronize the main workspace in production.');

echo $help->renderCommandHelp();
```

Detailed mode supports:

- title
- description
- usage
- commands
- arguments
- options
- examples
- wrapping long descriptions to terminal width

Recommended usage:

- `php bin/app` -&gt; render compact overview
- `php bin/app serve --help` -&gt; render detailed command help

Table generator
---------------

[](#table-generator)

```
use Krzysztofzylka\Console\Generator\Table;

$table = new Table();
$table->addColumn('Name', 'name');
$table->addColumn('Role', 'role', 'center');
$table->addColumn('Environment', 'environment');
$table->addColumn('Notes', 'notes', 'left', 18, true);
$table->addColumn('Requests', 'requests', 'right');
$table->addRow([
    'name' => 'Anna',
    'role' => 'Developer',
    'environment' => 'prod',
    'notes' => "Owns API rollout\nSupports on-call",
    'requests' => 1280,
]);
$table->addRow([
    'name' => 'Łukasz',
    'role' => 'QA',
    'environment' => 'stage',
    'notes' => 'Regression tests and smoke checks',
    'requests' => 315,
]);

$table->render();
$output = $table->renderToString();
```

Column options:

- `$align` supports `left`, `right`, `center`
- `$maxWidth` limits visible width
- `$truncate` trims long lines with `...`

Table options:

- `addRow(array $row)`
- `setShowHeader(bool $showHeader)`
- `setShowBorder(bool $showBorder)`
- `setMaxWidth(?int $maxWidth)`

Progress helpers
----------------

[](#progress-helpers)

```
use Krzysztofzylka\Console\ProgressBar;
use Krzysztofzylka\Console\Spinner;

$progress = new ProgressBar(5, 20);

for ($i = 1; $i setProgress($i, 'step ' . $i);
}

$progress->finish('completed');

$spinner = new Spinner();
$spinner->spin('Waiting...');
$spinner->finish('Done');
```

Colors
------

[](#colors)

```
use Krzysztofzylka\Console\Helper\Color;

echo Color::wrap('Success', 'green');
echo Color::wrap('Warning', 'yellow');
echo Color::wrap('Important', 'bold');
```

Supported names include:

- `black`
- `gray`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `graylight`
- `bold`
- `dim`
- `underline`
- `bg-white`
- `bg-gray`
- `bg-red`
- `bg-green`
- `bg-yellow`
- `bg-blue`
- `bg-magenta`
- `bg-cyan`

Named presets:

- `info`
- `success`
- `warning`
- `error`
- `muted`
- `title`
- `highlight`

Notes
-----

[](#notes)

- ANSI colors are automatically disabled when the output stream is not a TTY or when `NO_COLOR` is set.
- `Help` and `Table` use `mb_strwidth()` when available for better UTF-8 alignment.
- `Table` supports per-column alignment, multiline cells, optional headers, optional borders and global/per-column max width.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance86

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~86 days

Recently: every ~103 days

Total

11

Last Release

75d ago

PHP version history (2 changes)1.0.0PHP &gt;=8.0

1.0.9PHP &gt;=8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/b71301619d71d2798d3a84f23de616ac1f1c185ab72e4f03e925cff169b03a0d?d=identicon)[krzysztofzylka](/maintainers/krzysztofzylka)

---

Top Contributors

[![krzysztofzylka](https://avatars.githubusercontent.com/u/41385342?v=4)](https://github.com/krzysztofzylka "krzysztofzylka (15 commits)")

### Embed Badge

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

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

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.5k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71470.5k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20720.9k21](/packages/winbox-args)[tomatophp/filament-artisan

Simple but yet powerful library for running some artisan commands for FilamentPHP

3275.4k1](/packages/tomatophp-filament-artisan)

PHPackages © 2026

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