tomkyle/tabulate

Format 2D arrays as CLI console table, Markdown, CSV, YAML, JSON.

1.1.1 2025-06-10 13:54 UTC

This package is auto-updated.

Last update: 2025-06-10 13:55:05 UTC


README

License Packagist PHP version Tests

Format 2D arrays as CLI tables, Markdown, CSV, YAML, and JSON.

Requirements

  • PHP 8.3 or higher
  • Symfony Console component for SymfonyStyleTable
  • Symfony Yaml component for YamlTable

Installation

Install via Composer:

composer require tomkyle/tabulate

Quick Start

composer require tomkyle/tabulate
use tomkyle\Tabulate\TableFactory;

$data = [
    ['Name' => 'Alice', 'Age' => 30],
    ['Name' => 'Bob',   'Age' => 25],
];

$factory = new TableFactory();
$factory->fromString('markdown')($data);

Features

  • Multiple formats: CLI, Markdown, CSV, YAML, JSON
  • Column alignment: Auto-detection and manual override
  • Stream output: Direct file writing, memory-efficient processing
  • Factory pattern: Dynamic formatter creation for your CLI script with --format option support

Documentation

License

MIT License - see LICENSE file.