Download the PHP package hoathis/symfony-console-bridge without Composer
On this page you can find all versions of the php package hoathis/symfony-console-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package symfony-console-bridge

Hoa is a modular, extensible and structured set of PHP libraries. Moreover, Hoa aims at being a bridge between industrial and research worlds.
Hoathis\SymfonyConsoleBridge 
- Installation
- How to use
- Symfony
- Output
- Formatter
- Helpers
- Window
- Cursor
- Readline
- Pager
- Tput
All the examples in this readme are available and working in the test application.
Installation
With Composer, to include this library into your dependencies, you need to require
hoathis/symfony-console-bridge:
Please, read the website to get more informations about how to install.
Finally, install dependencies:
How to use
Symfony
To use this library with the Symfony framework, please use
the dedicated bundle:
hoathis/symfony-console-bundle.
Output
Hoathis\SymfonyConsoleBridge\Output\ConsoleOutput is an alternative to the
native ConsoleOutput which is able to detect output type and automatically
configure verbosity and text decoration.
Let's have the following command:
Running:
As you will see in your terminal, output will be decorated and verbose by default. However if you run:
The verbosity level will automatically be switched to very verbose because the output has detected that you were redirecting it to a file.
Here are the rules used to determine verbosity level and text decoration support:
| Verbosity | Decoration | |
|---|---|---|
| Pipe | normal | disabled |
| Redirect | very verbose | disabled |
| Terminal | verbose | enabled |
Those rules will only be used if you do not provide any verbosity level using command line arguments. If you want to redirect outputs to a file using the debug verbosity level, simply run:
You can still force ANSI output using the --ansi option:
Want to try it? Run
bin/console output:verbosityto get a live demo and code snippet.
Formatter
Hoathis\SymfonyConsoleBridge\Formatter\OutputFormatterStyle will let you do
everything you were able to do with the native symfony/console formatter with
some more cool things:
- supports
xterm-8colorcolor names, - supports
xterm-256colorcolor codes, - automatically translates hexadecimal color codes,
- supports text styling (normal, bold, underlined, blink and inverse).
To use those new OutputFormatterStyle, use the usual API:
As you can see in the previous example, you can replace built-in styles by simply redifining them with the new formatter.
Want to try it? Run
bin/console output:formatter:customorbin/console output:formatter:nativeto get a live demo and code snippet.
Helpers
The real power of the library comes from its helpers: they let you manage every terminal components. You will first have to manually load them:
Every helper has a dedicated test command. Just run
bin/console listto get a list.
Window
The window helper will let you manipulate the current terminal window. It provides several utility methods, each one being bound to an action:
Many other utility methods are available:
setTitle,getTitle,getLabelto manipulate terminal title,setSize,getSize,move,setPosition,getPositionto manipulate window position,minimize,restore,lower,raiseto manipulate window placement,scroll,refresh,copyto manipulate window content.
Want to try it? Run
bin/console helper:window:animateto get a live demo and code snippet.
Cursor
The cursor helper will let you manipulate the cursor. It provides several utility methods, each one being bound to an action:
Many other utility method are available:
move,moveToto change cursor position,getPositionto retrieve the current cursor position,saveandrestoreto save and restore the cursor position,clearto clear whole or part of the screen,hide,showandstyleto change cursor display options,colorizeandresetto manage text styling,bipto emit a bell.
Want to try it? Run
bin/console helper:cursor:drawto get a live demo and code snippet.
Readline
The readline helper will help you gather inputs from the user. It provides some methods to ask and validates user's inputs:
readwill prompt the user for an input,autocompletewill display a prompt and let the user input text and use autocompletion,selectwill display a list of choices to the user and let him select one or more values,validatewill keep asking for an input until it validates against a validator you provide.
Note that for select you can provide a special choice that will display as a
separator using 'label' => ReadlineHelper::SEPARATOR items in you choices
list.
Want to try it? Run
bin/console helper:readline:selectorbin/console helper:readline:autocompleteto get a live demo and code snippet.
Pager
The pager helper will let you display outputs through a pager so the user can
easily read and scroll. The helper provides two pagers: less and more. You
will have to feed them using a closure wrapping code producing output:
Want to try it? Run
bin/console helper:pager:lessorbin/console helper:pager:moreto get a live demo and code snippet.
Tput
The tput helper will help you get informed about user's terminal capabilities. The helper provides
a single entry point to all capabilities: the get method. Here is how you would do to get the clear_screen
capability:
Want to try it? Run
bin/console helper:tput:capabilitiesorbin/console helper:tput:echoorbin/console helper:tput:getto get a live demo and code snippet.
All versions of symfony-console-bridge with dependencies
hoa/console Version >=1.0,<3.0
symfony/console Version ~2.3,>=2.3.6|~3.0.0