Download the PHP package fyre/console without Composer
On this page you can find all versions of the php package fyre/console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package console
FyreConsole
FyreConsole is a free, open-source CLI library for PHP.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Static Methods
- Colors
- Styles
Installation
Using Composer
In PHP:
Basic Usage
$inputis the input stream, and will default toSTDIN(ornullfor non-CLI usage).$outputis the output stream, and will default toSTDOUT(or "php://output" for non-CLI usage).$erroris the error stream, and will default toSTDERR(or "php://output" for non-CLI usage).
Methods
Choice
Prompt to make a choice out of available options.
$textis a string representing the prompt text.$optionsis an array containing the options.$defaultis a string representing the default option, and will default to null.
Comment
Output comment text.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default to null.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default toConsole::DIM.
Confirm
Prompt to confirm with y/n options.
$textis a string representing the prompt text.$defaultis a boolean representing the default option, and will default to true.
Error
Output text to STDERR.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default toConsole::RED.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default to null.
Info
Output info text.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default toConsole::BLUE.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default to null.
Input
Read a line of input.
Progress
Output a progress indicator.
$stepis a number representing the current step, and will default to null.$totalStepsis a number representing the total steps, and will default to 10.
Sequential calls to this method will update the progress indicator. If the $step is set to null the indicator will be cleared.
Prompt
Prompt the user for input.
$textis a string representing the prompt text.
Success
Output success text.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default toConsole::GREEN.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default to null.
Table
Output a table.
$datais an array containing the table rows.$headeris an array containing the table header columns, and will default to [].
Warning
Output warning text.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default toConsole::YELLOW.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default to null.
Write
Output text to STDOUT.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default toConsole::YELLOW.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default to null.
Static Methods
Get Height
Get the terminal height (in characters).
Get Width
Get the terminal width (in characters).
Style
Style text for terminal output.
$textis a string representing the text.$optionsis an array containing the color options.coloris a number representing the text color, and will default to null.bgis a number representing the background color, and will default to null.styleis a number indicating the text style, and will default to null.
Wrap
Wrap text for terminal output.
$textis a string representing the text.$maxWidthis a number representing the maximum character width of a line, and will default to the terminal width.