Download the PHP package tobento/service-console without Composer
On this page you can find all versions of the php package tobento/service-console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package service-console
Console Service
Command Line Interface using Symfony Console as default implementation.
Table of Contents
- Getting started
- Requirements
- Highlights
- Documentation
- Console
- Create Console
- Add Command
- Run Console
- Execute Command
- Creating Commands
- Command
- Arguments and Options
- Abstract Command
- Using Signature
- Command
- Interactor
- Retrieving Argument and Option Values
- Retrieving Raw Input
- Writing Output
- Asking Questions
- Progress Bar
- Verbosity Levels
- Command Parameters
- Ignore Validation Errors Parameter
- Locking
- Signals
- Events
- Testing
- Symfony
- Symfony Console
- Symfony Custom Interactor
- Console
- Credits
Getting started
Add the latest version of the console service project running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
Documentation
Console
Create Console
Add Command
After Creating Commands you can add them in the console:
Run Console
Execute Command
You may want to execute a command instead of running the console.
Example with command class
Example with command name
Creating Commands
Command
You may use the to create simple commands.
Check out the Interactor section to learn more about it.
Arguments and Options
Arguments in detail
Options in detail
Abstract Command
Simply extend from the to create more complex commands.
Check out Arguments and Options for more detail.
Using Signature
You may use the as an alternative way to define the name, description, arguments and options of your command.
Arguments
- required, expecting single value
- optional, expecting single value
- required and variadic, expecting multiple values
- optional and variadic, expecting multiple values
- optional with as default value
- optional with as default value
- optional and variadic with and as default values
Options
- acts as boolean value, if exists , otherwise
- with as short name
- with as default value
- with as default value
- variadic, expecting multiple values
- variadic with and as default values
Options are optional in general!
Interactor
The interactor let you interact with the input and output from the console while handling your command:
Retrieving Argument and Option Values
Retrieve input argument(s) and option(s) if specified. See Arguments and Options.
Argument details
Option details
Retrieving Raw Input
You may use the method to retrieve the raw input that was passed to the command.
Writing Output
Writing formatted output
You may write formatted output by the following way:
Writing tables
Asking Questions
Secret question
You may ask a secret question:
Confirmation question
You may ask for confirmation:
Choice question
You may ask a choice question:
Progress Bar
Verbosity Levels
- No message output
- Normal output
- Low verbosity
- Medium verbosity
- High verbosity
Command Parameters
Ignore Validation Errors Parameter
You may add the parameter to ignore validation errors which may be useful in some cases.
Locking
Not supported yet.
Signals
Not supported yet.
Events
You may listen to the following events if you have defined a event listener in the console:
Event | Description |
---|---|
The Event is fired executing the console command. | |
The Event is fired executing the console command. |
Testing
You may test commands using the .
You may check out the for examples.
Passing input arguments and options
Passing Container Or Console
With input
You may use the method returning a new instance:
Symfony
Symfony Console
Symfony Custom Interactor
You may create a custom interactor using the parameter:
Credits
- Tobias Strub
- All Contributors
- Symfony Console
All versions of service-console with dependencies
psr/container Version ^2.0
psr/event-dispatcher Version ^1.0
tobento/service-autowire Version ^1.0.9
symfony/console Version ^6.0