dklis / chalk-php
PHP library to beautify your CLI messages
1.0.6
2022-02-26 12:50 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.6
- vimeo/psalm: ^4.19
README
Chalk is a small PHP library for adding ANSI colors and other text transformations to CLI text output.
Requirements
Chalk requires PHP version 8.1 or greater.
Installation
The easiest way to get started with Chalk is through composer:
# Install as dependency
composer require "dklis/chalk-php"
Usage
<?php use Dklis\Chalk\Chalk; // ... // Foreground color $redMessage = Chalk::red('A red message'); // Background color $redBgMessage = Chalk::redBG('A message with red background'); // Transformations $bold = Chalk::bold('A bold message'); $underline = Chalk::underline('An underlined message'); // Multiple transformations $multiTransform = Chalk::transform('A message', 'blue', 'redBG', 'underscore', 'bold')
Default colors
Default transformations
Adding your own
To use a custom color palette, simply create a string backed Enum implementing \Dklis\Chalk\Contracts\ColorPaletteInterface
and call the Chalk::create
function to create your messages.
Issues
Bug reports and feature requests can be submitted on the Github Issue Tracker.