New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

whatsdiff/chewie

whatsdiff's fork of joetannenbaum/chewie — a PHP TUI framework built on Laravel Prompts
1,330
Install
composer require whatsdiff/chewie
Latest Version:0.1.13
Last Updated:Aug 8, 2026
Links: GitHub  ·  Packagist
Maintainer: SRWieZ

[!WARNING] This is a fork. You almost certainly want joetannenbaum/chewie instead. This repository exists to serve whatsdiff and is not a general-purpose release of Chewie.

It tracks upstream main with two changes:

  • Output\Lines measures columns with mb_strwidth() instead of mb_strlen(). Emoji and CJK characters count as one character but occupy two terminal cells, so a column containing them was under-padded and the column beside it drifted out of alignment.
  • The hardcoded version field is gone from composer.json, so Composer can read the version from the tag rather than rejecting any tag that disagrees with the manifest.

Both are meant to go upstream. If they land there, this fork goes away.

Chewie

Chewie

Chewie is a package that helps you build text-based user interfaces (TUIs) with Laravel Prompts. It helps to reduce some of the boilerplate code and adds some helpers for alignment, animation, and more.

[!WARNING] This package is currently in active development. The API is subject to change. Documentation will also improve over time.

Installation

composer require joetannenbaum/chewie

Registering Renderers

use App\Renderers\DemoRenderer;
use Chewie\Concerns\RegistersRenderers;

class Demo extends Prompt
{
    use RegistersRenderers;

    public function __construct()
    {
        $this->registerRenderer(DemoRenderer::class);
    }
}

You can also tell Chewie that all of your renderers live within a specific namespace, then Chewie will resolve your renderers automatically.

For example, if you call the following in your AppServiceProvider:

use Chewie\Renderer;

class AppServiceProvider
{
    public function boot()
    {
        Renderer::setNamespace('App\\Renderers');
    }
}

Then you can simply do the following when registering renderers. Chewie assumes your renderer class will be your app class + Renderer:

use Chewie\Concerns\RegistersRenderers;

class Demo extends Prompt
{
    use RegistersRenderers;

    public function __construct()
    {
        // Will register App\Renderers\DemoRenderer
        $this->registerRenderer();
    }
}

Drawing Art

You can easily print ASCII art from a file out to the terminal in your renderer:

use Chewie\Concerns\DrawsArt;

class DemoRenderer extends Renderer
{
    use DrawsArt;

    public function __invoke(Demo $prompt): string
    {
        // Returns a collection of the lines from your art,
        // assumes a ".txt" extension
        $this->artLines(storage_path('my-art/horse'))
            ->each($this->line(...));

        return $this;
    }
}

You can also tell Chewie where all of your art files live:

use Chewie\Art;

class AppServiceProvider
{
    public function boot()
    {
        Art::setDirectory(storage_path('my-art'));
    }
}

which allows you to simplify the artLines call to:

use Chewie\Concerns\DrawsArt;

class DemoRenderer extends Renderer
{
    use DrawsArt;

    public function __invoke(Demo $prompt): string
    {
        $this->artLines('horse')->each($this->line(...));

        return $this;
    }
}

Alignment

Chewie comes with methods that help align content within the terminal.

use Chewie\Concerns\Aligns;

class DemoRenderer extends Renderer
{
    use Aligns;

    public function __invoke(Demo $prompt): string
    {
        $width = $prompt->terminal()->cols();
        $height = $prompt->terminal()->lines();

        $lines = [
            'Hello!',
            'My name is Joe',
        ];

        $this->centerHorizontally($lines, $width)
            ->each($this->line(...));

        $this->centerVertically($lines, $height)
            ->each($this->line(...));

        $this->center($lines, $width, $height)
            ->each($this->line(...));

        $this->line($this->spaceBetween($width, ...$lines));

        $this->pinToBottom($height, function() {
            $this->newLine();
            $this->line('This is pinned to the bottom!');
        });

        return $this;
    }
}

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released License
0.1.13
0.1.12