antibiotics11/ansi-styler

Utility for applying ANSI colors and text styles to console output.

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

pkg:composer/antibiotics11/ansi-styler

v1.0 2024-04-15 07:45 UTC

This package is auto-updated.

Last update: 2025-09-15 11:21:59 UTC


README

A PHP utility for applying ANSI colors and text styles to console output.

use antibiotics11\AnsiStyler\{AnsiColorCode, AnsiFormatter};

// create a new AnsiFormatter instance
$styler = new AnsiFormatter();

// apply yellow background color, red foreground color and bold style
$formattedText = $styler->withBackgroundColor(AnsiColorCode::BACKGROUND_YELLOW)
                        ->withForegroundColor(AnsiColorCode::FOREGROUND_RED)
                        ->withBold()
                        ->format("Hello, World!");

printf("%s\r\n", $formattedText);

// reinitialize the AnsiFormatter
$styler->initialize();

screenshot

Requirements

  • PHP >= 8.1

Installation

composer require antibiotics11/ansi-styler