Download the PHP package metashock/jm_console without Composer
On this page you can find all versions of the php package metashock/jm_console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download metashock/jm_console
More information about metashock/jm_console
Files in metashock/jm_console
Package jm_console
Short Description Jm_Console is a library for terminal colors
License BSD-3
Informations about the package jm_console
J@m; Console
ANSI console library for PHP
Installation
To install Jm_Console you can use the PEAR installer or get a tarball and install the files manually.
Using the PEAR installer
If you haven't discovered the metashock pear channel yet you'll have to do it. Also you should issue a channel update:
pear channel-discover metashock.de/pear
pear channel-update metashock
After this you can install Jm_Console. The following command will install the lastest stable version with its dependencies:
pear install -a metashock/Jm_Console
If you want to install a specific version or a beta version you'll have to specify this version on the command line. For example:
pear install -a metashock/Jm_Console-0.3.0
Manually download and install files
Alternatively, you can just download the package from http://www.metashock.de/pear and put into a folder listed in your include_path. Please refer to the php.net documentation of the include_path directive.
Usage
Basics
Before accessing Jm_Console's functions you'll first get an object reference to it. Jm_Console is a singleton class meaning there is just a single reference available. To get the reference call:
Printing output
Jm_Console provides write access to STDOUT and STDERR. Output is done using the following functions:
Terminal colors
The ANSI Terminal standard allows to define a foreground color, a background color and choose a text decoration mode. Jm_Console aims to provide an intuitive access to terminal colors when printing text.
The simplest thing is to just specifiy a foreground color:
or just specify a text decoration:
or specify both a foreground color and a text decoration:
If want to set the background color you'll have to use the prefix bg:
in front of the color. Otherwise Jm_Console couldn't make a difference between foreground color and background color:
Table: Available Graphics modes
Colors | Text Decorations |
---|---|
|
|
Cursor positioning
ANSI terminals support positioning of the cursor.
It is also possible to store the cursor position and restore it later:
Example
Drawing a progress bar on terminal
API documentation
The API docs can be found here: http://metashock.de/docs/api/Jm/Console/index.xhtml