PHPackages                             artisan-build/parfait - 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. artisan-build/parfait

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

artisan-build/parfait
=====================

A framework-agnostic, component-based TUI layout and rendering system for PHP terminal applications

v0.1.0(1mo ago)310↓20%[1 issues](https://github.com/artisan-build/parfait/issues)1MITPHPPHP ^8.2

Since Jun 3Pushed 1mo agoCompare

[ Source](https://github.com/artisan-build/parfait)[ Packagist](https://packagist.org/packages/artisan-build/parfait)[ Docs](https://github.com/artisan-build/parfait)[ RSS](/packages/artisan-build-parfait/feed)WikiDiscussions main Synced 1w ago

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

 [![Parfait](art/logo.png)](art/logo.png)

 A framework-agnostic, component-based TUI layout and rendering system for PHP terminal applications.

---

Why Parfait?
------------

[](#why-parfait)

Building a terminal UI usually means hand-managing ANSI codes, cursor math, and Unicode width edge cases. Parfait gives you a **declarative, component-based API** instead — you describe the UI as a tree of components, and Parfait renders it to a string.

- 🧩 **Components** — `Panel`, `Modal`, `Accordion`, `FileTree`, `SelectList`, `NodeCanvas`, `Text`, and more, each with a fluent API.
- 📐 **Layouts** — compose `Layout::columns()` / `Layout::rows()` with ratio-based sizing.
- 🎨 **256-color theming** — a semantic `Color` enum that emits correct ANSI codes.
- 📏 **Unicode-correct width** — emoji, CJK, combining marks, and ANSI escapes are measured accurately.
- 🪟 **Portals** — dropdowns, modals, and toasts render onto higher layers instead of being clipped.
- 🧪 **Effortless testing** — components are pure functions: *state in → `render()` → string out*. No terminal required.
- 🪶 **Zero framework dependencies** — needs only PHP 8.2+ and [`soloterm/grapheme`](https://github.com/soloterm/grapheme).

Parfait layers cleanly on top of [Laravel Prompts](https://github.com/laravel/prompts)for input/render loops, but depends on **neither Laravel nor Prompts** — you can drive it from any PHP terminal program.

Requirements
------------

[](#requirements)

- PHP `^8.2`
- `ext-mbstring` and `ext-intl` (for grapheme-aware width)

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

[](#installation)

```
composer require artisan-build/parfait
```

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

[](#quick-start)

Every component knows the space it has via a `Container`, and renders to a string you print yourself:

```
use ArtisanBuild\Parfait\Components\Panel;
use ArtisanBuild\Parfait\Components\Text;
use ArtisanBuild\Parfait\Enums\Color;
use ArtisanBuild\Parfait\Support\Container;

$panel = Panel::make('welcome')
    ->bordered()
    ->title('Parfait')
    ->body(Text::make('greeting', 'Welcome to the TUI!')->fg(Color::Cyan))
    ->setContainer(new Container(width: 40, height: 5));

echo $panel->render();
```

```
╭── Parfait ───────────────────────────╮
│Welcome to the TUI!                   │
│                                      │
│                                      │
╰──────────────────────────────────────╯

```

### Composing a layout

[](#composing-a-layout)

`Layout` arranges child components and hands each one a correctly-sized `Container`:

```
use ArtisanBuild\Parfait\Components\Panel;
use ArtisanBuild\Parfait\Components\Text;
use ArtisanBuild\Parfait\Layouts\Layout;
use ArtisanBuild\Parfait\Support\Container;

$ui = Layout::columns(1, 3)            // sidebar : main = 1 : 3
    ->add(Panel::make('sidebar')->sidebar()->title('Files'))
    ->add(Panel::make('main')->bordered()->body(Text::make('body', 'Editor')))
    ->setContainer(new Container(width: 100, height: 30));

echo $ui->render();
```

Components
----------

[](#components)

ComponentPurpose`Text` / `Stack`Inline styled text and vertical content composition`Panel`Bordered / sidebar / minimal containers with header, body, footer`Modal`Overlay dialogs with shadow rendering (via portals)`Toast`Transient notifications`Accordion`Expandable tree-style navigation`SelectList`Scrollable, selectable lists`FileTree`Filesystem browser with search and exclude patterns`Input` / `TextArea`Single- and multi-line text entry`CommandLine`Command-palette style input`ProgressBar`Determinate progress display`StatusBar` / `AppHeader`Chrome for the top and bottom of the screen`NodeCanvas`Node-graph visualization with automatic layoutEach component lives in `src/Components/` alongside a co-located `*Renderer`where rendering is non-trivial — see [Architecture](#architecture).

Architecture
------------

[](#architecture)

Parfait uses a **co-located renderer** pattern:

- `Component.php` holds **state and props** (public properties, fluent setters).
- `ComponentRenderer.php` turns that state into a **string**.

This keeps rendering logic isolated and makes components trivial to test — construct one, set its container, assert on the rendered string. The base `Component` provides styling helpers (`applyStyle`, width/truncate utilities), view-state storage, and the portal hook.

```
┌─────────────────────────────────────────────┐
│  Your program (owns data, handles events)    │
├─────────────────────────────────────────────┤
│  Parfait (layout + components → string)      │
├─────────────────────────────────────────────┤
│  Terminal                                    │
└─────────────────────────────────────────────┘

```

See [`DESIGN.md`](./DESIGN.md) for the full design rationale.

Documentation
-------------

[](#documentation)

The [`docs/`](./docs) directory covers each subsystem in depth:

1. [Introduction](./docs/01-introduction.md)
2. [Components](./docs/02-components.md)
3. [Layouts](./docs/03-layouts.md)
4. [Styles](./docs/04-styles.md)
5. [Navigation](./docs/05-navigation.md)
6. [View State](./docs/06-view-state.md)
7. [Events](./docs/07-events.md)
8. [Testing](./docs/08-testing.md)
9. [Portals](./docs/09-portals.md)

Testing
-------

[](#testing)

Components are pure functions, so tests need no terminal or framework:

```
use ArtisanBuild\Parfait\Components\Text;
use ArtisanBuild\Parfait\Enums\Color;

it('styles text', function () {
    expect(Text::make('t', 'hi')->fg(Color::Cyan)->render())
        ->toBe("\e[38;5;81mhi\e[0m");
});
```

Run the suite:

```
composer test       # pest
composer analyse    # phpstan
composer lint       # pint (use lint:test to check without fixing)
```

Contributing
------------

[](#contributing)

Contributions are welcome — see [CONTRIBUTING.md](./CONTRIBUTING.md) for the dev setup, coding standards, and quality gates.

License
-------

[](#license)

Parfait is open-source software licensed under the [MIT license](./LICENSE).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance83

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

51d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/63312522f1920cf5b3c34ea474511a484162b36166a33ae4b9fde6c65ab2c2fc?d=identicon)[ProjektGopher](/maintainers/ProjektGopher)

---

Top Contributors

[![ProjektGopher](https://avatars.githubusercontent.com/u/1688608?v=4)](https://github.com/ProjektGopher "ProjektGopher (9 commits)")

---

Tags

cliconsoleterminalcomponentslayoutansituiRendering

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/artisan-build-parfait/health.svg)

```
[![Health](https://phpackages.com/badges/artisan-build-parfait/health.svg)](https://phpackages.com/packages/artisan-build-parfait)
```

###  Alternatives

[symfony/console

Eases the creation of beautiful and testable command line interfaces

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

Comprehensive TUI library heavily influenced by Ratatui

6011.0M15](/packages/php-tui-php-tui)[php-school/cli-menu

A command line menu helper in PHP

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

Aplus Framework CLI Library

2351.7M6](/packages/aplus-cli)[splitbrain/php-cli

Easy command line scripts for PHP with opt parsing and color output. No dependencies

178866.3k32](/packages/splitbrain-php-cli)[alecrabbit/php-console-spinner

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

24038.0k2](/packages/alecrabbit-php-console-spinner)

PHPackages © 2026

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