Download the PHP package enco/cli-styles without Composer
On this page you can find all versions of the php package enco/cli-styles. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download enco/cli-styles
More information about enco/cli-styles
Files in enco/cli-styles
Package cli-styles
Short Description Package to manage cli output styles (color, background, font style)
License GPL-3.0-only
Informations about the package cli-styles
CLI styles for PHP
With this library you can stylize CLI output
Available styles:
- Bold
- Italic
- Blink
- Underline
- Cross line
- Over line
- Text color
- Background color
How to use:
You can add different styles to different parts of text. For example, you specify two styles with names 'success' and 'error'. So your text must be like:
NOTE: You can`t use tags hierarchy. This text will be incorrect:
In your code you must use 2 classes: \Enco\CliStyles
and \Enco\Style
\Enco\Style
uses to define style
You are obligated to set style name. Otherwise, the exception will be thrown
The name must match ^[a-z0-9_-]+$
regular expression
Available methods:
Also, you can specify default style, that applies to text without tags
To do this you just need to specify \Enco\Style::DEFAULT_STYLE_NAME
constant as name of style
\Enco\CliStyles
uses to apply styles to text
You must add styles, that you want to use
Available methods:
You can use $cliStylesObject
to echo text. Styles will be applied automatically. Example:
Also, you can escape tag:
Output will be:
PHP code example:
Cli cursor management
You can manage CLI cursor position. For ex. mov cursor or set absolute position
To manage CLI cursor you must use \Enco\CliCursor
Available methods:
You must be careful to use \Enco\CliStyles
and \Enco\CliCursor
, because \Enco\CliCursor
in some cases can reset styles (when new text override styled text)
Code example:
Output will be:
You always can ask questions to <[email protected]>