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

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

switon/console
==============

Reusable terminal primitives including progress bars, width detection, and ANSI styling for Switon Framework

v1.0.0(1mo ago)0404MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 1mo agoCompare

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

READMEChangelogDependencies (4)Versions (2)Used By (4)

Switon Console Package
======================

[](#switon-console-package)

[![CI](https://camo.githubusercontent.com/09949d3cdd6293b7a98230126709356b075f61df2cfa68fa7ac897fbaee41c79/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f636f6e736f6c652f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/console/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Reusable terminal primitives for progress bars, terminal width detection, and ANSI styling in Switon Framework.

Highlights
----------

[](#highlights)

- **Progress bars:** `ProgressBarInterface` with elapsed and remaining time rendering.
- **Width detection:** `TerminalWidthDetectorInterface` with Unix and Windows fallbacks.
- **ANSI style flags:** `Colors` bitmask constants for foreground, background, and text attributes.
- **Narrow contracts:** swap progress or width implementations without changing call sites.

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

[](#installation)

```
composer require switon/console
```

The package ships primitives only; `switon/cli` wires them for command authoring.

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

[](#quick-start)

```
use Switon\Console\Colors;
use Switon\Console\ProgressBarInterface;
use Switon\Core\Attribute\Autowired;
use Switon\Core\ConsoleInterface;

final class ImportUsers
{
    #[Autowired] protected ProgressBarInterface $progressBar;
    #[Autowired] protected ConsoleInterface $console;

    public function run(array $rows): void
    {
        $this->progressBar->start(count($rows));

        foreach ($rows as $row) {
            $this->importRow($row);
            $this->progressBar->advance();
        }

        $this->progressBar->finish();
        $this->console->writeLn(
            $this->console->colorize('Import complete', Colors::FC_LIGHT_GREEN | Colors::AT_BOLD)
        );
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

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

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (1 commits)")

---

Tags

ansiconsoleswitonterminalconsoleterminalansiswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

9.8k1.1B14.3k](/packages/symfony-console)[php-school/cli-menu

A command line menu helper in PHP

1.9k1.2M30](/packages/php-school-cli-menu)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

6011.0M15](/packages/php-tui-php-tui)[recca0120/terminal

run laravel artisan command in web application

885419.2k2](/packages/recca0120-terminal)[clue/term-react

Streaming terminal emulator, built on top of ReactPHP.

10411.0M3](/packages/clue-term-react)[aplus/cli

Aplus Framework CLI Library

2351.7M6](/packages/aplus-cli)

PHPackages © 2026

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