antibiotics11 / ansi-styler
Utility for applying ANSI colors and text styles to console output.
v1.0
2024-04-15 07:45 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();
Requirements
- PHP >= 8.1
Installation
composer require antibiotics11/ansi-styler