New

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

jeffersongoncalves/laravel-zero-console

Reusable traits for Laravel Zero commands: output formatting (tables, state colorization, dates), standardized API error handling, and cwd/argument path resolution.
1,002 1

Larablocks Analysis

jeffersongoncalves/laravel-zero-console works with Laravel 11, 12 and 13 (latest release v1.0.2, Oct 29, 2026).

Promising: maintained and up to date, meets 2 of 4 checks; not yet widely used.

  • Works with Laravel 13, the current version
  • Released in the last 12 months (Oct 29, 2026)
  • 277 downloads a month (needs 10,000)
  • 1 GitHub star (needs 100)

State

Actively maintained
  • Last stable release: Oct 29, 2026.
  • 3 releases in the last 12 months.
  • First released: Jun 23, 2026.
  • Monthly downloads: 277.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require jeffersongoncalves/laravel-zero-console
Latest Version:v1.0.2
PHP:^8.2
Laravel:11 · 12 · 13
License:MIT
Last Updated:Nov 24, 2026
Links: GitHub  ·  Packagist
Maintainer: jeffersongoncalves

laravel-zero-console

laravel-zero-console

Buy Me A Coffee

Reusable traits for Laravel Zero (and plain Laravel) commands. Extracted from real CLIs that kept copy-pasting the same helpers: output formatting, standardized API error handling, and path resolution.

Why

Every CLI ends up reimplementing the same chores: rendering tables that gracefully handle empty results, colorizing status strings, formatting dates, swallowing API exceptions into clean exit codes, and turning a path argument (or the cwd) into a real filesystem path. This package ships those as small, focused traits.

Installation

composer require jeffersongoncalves/laravel-zero-console

Requires PHP ^8.2 and illuminate/console ^11.0|^12.0.

Traits

FormatsOutput

Use inside an Illuminate\Console\Command (relies on $this->table() and $this->components).

use Illuminate\Console\Command;
use JeffersonGoncalves\LaravelZero\Console\FormatsOutput;

class ListCommand extends Command
{
    use FormatsOutput;

    public function handle(): int
    {
        // Renders a table, or "No results found." when $rows is empty.
        $this->renderTable(['ID', 'State', 'Updated'], $rows);

        $this->line($this->colorize('OPEN', $this->stateColor('OPEN'))); // <fg=blue>OPEN</>
        echo $this->formatDate('2024-01-02 03:04:05');                   // 2024-01-02 03:04
        echo $this->formatDate(null);                                    // -

        return self::SUCCESS;
    }
}

Methods:

  • renderTable(array $headers, array $rows): void — renders a table, or an info message when there are no rows.
  • colorize(string $value, string $color): string — wraps a value in <fg=color>...</> tags.
  • stateColor(string $state): string — case-insensitive lookup of a console color for a state.
  • stateColors(): array — the state→color map. Override it to customize. The default merges pull-request states (OPEN, MERGED, DECLINED, SUPERSEDED) with issue-tracker states (TODO, IN PROGRESS, DONE).
  • formatDate(?string $date, string $format = 'Y-m-d H:i'): string — formats a date string via DateTime; returns - for null/empty/invalid input.

Customizing the color map:

protected function stateColors(): array
{
    return [
        'SHIPPED' => 'magenta',
        'OPEN' => 'cyan',
    ];
}

HandlesApiErrors

use JeffersonGoncalves\LaravelZero\Console\HandlesApiErrors;

class FetchCommand extends Command
{
    use HandlesApiErrors;

    public function handle(): int
    {
        return $this->handleApiErrors(function () {
            $data = $this->api->fetch(); // may throw any Throwable

            $this->renderTable(['ID'], $data);

            return self::SUCCESS;
        });
    }
}
  • handleApiErrors(callable $callback): int — runs the callback; on success returns its int result (or SUCCESS when it returns null); on any Throwable prints the message via $this->components->error() and returns FAILURE.

ResolvesPath

use JeffersonGoncalves\LaravelZero\Console\ResolvesPath;

$path = $this->resolvePath($this->argument('path')); // realpath, or cwd when empty
$cwd  = $this->resolveCwd();                          // realpath of getcwd()
  • resolvePath(?string $argument = null): string — resolves an optional argument to its realpath, falling back to the cwd; returns the original input when the path does not exist.
  • resolveCwd(): string — the current working directory resolved to its realpath.

Testing

composer install
composer test

License

MIT

Alternatives to jeffersongoncalves/laravel-zero-console

nunomaduro/termwind

It's like Tailwind CSS, but for the console.

359,708,065 2,505
laravel-zero/framework

The Laravel Zero Framework.

1,897,680 358
mehrancodes/laravel-harbor

A CLI tool to Quickly create On-Demand preview environment for your apps.

114,649 102
artisan-toolbox/maintainer

Automated validation, quality assurance, versioning, and release workflows for L...

2,282 0
rahul900day/laravel-console-spinner

Laravel Console Spinner is a spinner output for Laravel command line.

136,911 76

Version History

Version Released PHP Laravel License
v1.0.2 ^8.2 ^11.0|^12.0|^13.0 MIT
v1.0.1 ^8.2 ^11.0|^12.0 MIT
v1.0.0 ^8.2 ^11.0|^12.0 MIT