Download the PHP package weew/console without Composer
On this page you can find all versions of the php package weew/console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package console
Console application
Table of contents
- Installation
- Introduction
- Console
- Input
- Output
- Widgets
- TableWidget
- Helpers
- PromptHelper
- Related projects
Installation
composer require weew/console
Introduction
This package provides a convenient skeleton for console application. Optically, heavily inspired by the symfony console it has it similarities and differences. Describing commands, parsing console arguments, styling and colorization of output, question helpers etc., all this is included inside this package. In related projects you'll find a list of used components that you might also use separately from this package.
Note: this package has not been tested on windows. Windows contributions are highly appreciated.
Console
To start building your console app, you need to instantiated a new console first.
Commands
Commands are the pieces of logic that you might plug and play into your console application. A command can by anything. There is no interface contract that you must fulfill. This design choice was made because of the dependency injection support for the weew/console-container-aware package.
Your command must have the setup
and run
method. For further information about configuration of commands refer to the weew/console-arguments package.
All the important functionality is available trough instances of IInput
and IOutput
. There are many more things you can do, just take a look at it. All you have to do now is to register your command on the console.
Running your command is as easy as pie.
You can prevent a command from executing in parallel setting the appropriate flag.
Input
Input contains all the information about the received arguments and offers some apis for interaction with the user.
This is how you can retrieve the current command:
You can access arguments and options that were matched for the command:
You can prompt user for input using this methods:
Output
Output is used to print information to the terminal. It uses the weew/console-formatter for styling and formatting of the text.
Widgets
Widgets are small and reusable classes that serve as a kind of ui elements.
TableWidget
This widget allows you to easily print simple tables.
Helpers
There are several helpers that you might use for interaction with the user.
PromptHelper
This helper allows you to prompt user for different kinds of input.
Related projects
- Console formatter Used for styling of output
- Console arguments Used for parsing of arguments
- Container aware console Container aware version of this package
All versions of console with dependencies
weew/console-formatter Version ^2.1
weew/helpers-array Version ^1.2
weew/helpers-string Version ^1.7
weew/json-encoder Version ^1.0
weew/helpers-filesystem Version ^1.2