Console - The Console component eases the creation of beautiful and testable command line interfaces.

Overview

Console Component

The Console component eases the creation of beautiful and testable command line interfaces.

Sponsor

The Console component for Symfony 5.4/6.0 is backed by Les-Tilleuls.coop.

Les-Tilleuls.coop is a team of 50+ Symfony experts who can help you design, develop and fix your projects. We provide a wide range of professional services including development, consulting, coaching, training and audits. We also are highly skilled in JS, Go and DevOps. We are a worker cooperative!

Help Symfony by sponsoring its development!

Resources

Credits

Resources/bin/hiddeninput.exe is a third party binary provided within this component. Find sources and license at https://github.com/Seldaek/hidden-input.

Comments
  • Added ValidableQuestion

    Added ValidableQuestion

    With ValidableQuestion you can do things like:

    $question = new ValidableQuestion("Give me something: ", ["required"]);
    

    or

    $question = new ValidableQuestion("Give me a number: ", ["numeric"]);
    

    I needed to exctract this out and now I share it here. It's just an idea of a functionality that I had to extend into this amazing package. Hope it helps.

    Thanks :)

    opened by p4bloch 6
  • Multi-lined quoted parameters

    Multi-lined quoted parameters

    I added a few lines to the Shell.php file, so the user can now pass quoted arguments to commands, continue to write then in the next lines, and then close the quoted param.

    The called command will receive this param with \n for each line the user used.

    opened by felipenmoura 3
  • Default command

    Default command

    For stand alone applications passing a command is mandatory but most of the times not really necessary

    So instead of calling my application like this /myapp.php mycommand --my_option I can just write ./myapp.php --my_option

    this PR allows for it while allowing to add (and execute) more than one command

    You just need to add $app->setDefaultCommandName('command:name'); and if the command is not found the default one will be executed

    includes unit tests and does not breack BC

    opened by francodacosta 3
  • Fix completion script affecting $IFS

    Fix completion script affecting $IFS

    Set COMP_WORDBREAKS instead of IFS.

    More in-depth explanation:

    IFS affects other things not related to programmable completion, such as how the shell breaks up argument lists.

    For example, by default this splits the unquoted variable as-expected:

    OPTION_LIST='foo bar'
    for OPT in $OPTION_LIST; do printf '%s\n' "$OPT"; done
    > foo
    > bar
    

    Changing IFS makes the variable not split as expected, printing all on one line:

    IFS=$'\n'
    for OPT in $OPTION_LIST; do printf '%s\n' "$OPT"; done
    > foo bar
    

    This PR changes it to use $COMP_WORDBREAKS which specifically affects how programmable completion works, instead of affecting and effectively poisoning how the user's shell works.

    opened by h3xx 2
  • Update InputOption.php

    Update InputOption.php

    Hi, there is missed $name and $description params comment in InputOpion __construct, because of that magneto 2 code generator fails to generate code because of parameters type inconsistency. I see that at leas in version v4.4.24 comment was in place.

    opened by piterpascko 2
  • Readd missing php-doc parameter for constructor

    Readd missing php-doc parameter for constructor

    partly revert the php constroctur php doc (readd missing php-doc for $name and $description) even if they not that meaningfull

    This is needed as Magento2 uses this library and needs all php-doc parameter for interception compilation. if there are any missing parameters (in this case $name and $description) break compile step as the parameters are missmatching the actual parameters:

    image

    (AbstractConfigOption extends InputOption)

    opened by brosenberger 2
  • Validation errors hidden and $input never bound if there are validation errors

    Validation errors hidden and $input never bound if there are validation errors

    Currently, $input->setInputBound(true) happens even if the first $input->bind() is unsucessful. This means it won't run the 2nd time, which is when validation errors are actually shown! This PR will only set $input->setInputBound(true) if the 1st $input->bind() was actually successful.

    opened by dsnopek 2
  • Allow to pass the verbosity level to the --verbose long option.

    Allow to pass the verbosity level to the --verbose long option.

    The help text for the verbosity option mentions that it is possible to pass a value to set the verbosity level:

      -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
    

    However, when I try this I get an error message:

    $ php application.php demo:greet Fabien --verbose=3
    
      [Symfony\Component\Console\Exception\RuntimeException]  
      The "--verbose" option does not accept a value.         
    

    The -vvv option works fine, but the POSIX long option --verbose doesn't accept a value. This is clearly the intention since these values are being read in Application::configureIO():

                if ($input->hasParameterOption('-vvv', true) || $input->hasParameterOption('--verbose=3', true) || $input->getParameterOption('--verbose', false, true) === 3) {
    

    The solution is to simply change the input option from VALUE_NONE to VALUE_OPTIONAL.

    opened by pfrenssen 2
  • Allow the default command to be non-interactive

    Allow the default command to be non-interactive

    At the moment the default command receives an $input object with any command-line options wiped out. It should be allowed to run a default command with options... and at least with the interactivity setting passed through.

    opened by pjcdawkins 2
  • allow getting of $catchExceptions

    allow getting of $catchExceptions

    Im working on a laravel pull request which utlises the Console\Application.

    I need to set $catchExceptions to false for this, which is fine, theres a setter for it.

    However ideally i should be able to save the properties current state before changing it, allowing me to restore it, which isnt currently possible as there is no getter method.

    This solves that problem.

    opened by leemason 2
  • Add remove function to remove a console command

    Add remove function to remove a console command

    Usefull in shell mode to dynamically change commands list.

    You can have commands becomming unavalable betwen context switching and with this function remove them so they dont appear anymore in list.

    opened by tygerlord 2
Releases(v6.2.3)
  • v6.2.3(Dec 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.2.2...v6.2.3)

    • bug #48784 Correctly overwrite progressbars with different line count per step (ncharalampidis)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.9(Dec 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.1.8...v6.1.9)

    • bug #48784 Correctly overwrite progressbars with different line count per step (ncharalampidis)
    • bug #48681 Revert "bug #48089 Fix clear line with question in section (maxbeckers) (chalasr)
    • bug #48089 Fix clear line with question in section (maxbeckers)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.17(Dec 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.0.16...v6.0.17)

    • bug #48784 Correctly overwrite progressbars with different line count per step (ncharalampidis)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.17(Dec 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v5.4.16...v5.4.17)

    • bug #48784 Correctly overwrite progressbars with different line count per step (ncharalampidis)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.2(Dec 16, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.2.1...v6.2.2)

    • bug #48681 Revert "bug #48089 Fix clear line with question in section (maxbeckers) (chalasr)
    • bug #48580 Fix missing command not matching namespace error message (Titouan Galopin)
    • bug #48089 Fix clear line with question in section (maxbeckers)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.1(Dec 6, 2022)

  • v6.2.0(Nov 30, 2022)

  • v6.2.0-RC2(Nov 28, 2022)

  • v6.1.8(Nov 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.1.7...v6.1.8)

    • bug #48179 Support completion for bash functions (Chi-teck)
    • bug #48217 Improve error message when shell is not detected in completion command (GromNaN)
    • bug #48210  Fix signal handlers called after event listeners and skip exit (GromNaN)
    • bug #47998 Fix console ProgressBar::override() after manual ProgressBar::cleanup() (maxbeckers)
    • bug #48085 Tell about messenger:consume invalid limit options (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.16(Nov 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.0.15...v6.0.16)

    • bug #48179 Support completion for bash functions (Chi-teck)
    • bug #48217 Improve error message when shell is not detected in completion command (GromNaN)
    • bug #48210  Fix signal handlers called after event listeners and skip exit (GromNaN)
    • bug #47998 Fix console ProgressBar::override() after manual ProgressBar::cleanup() (maxbeckers)
    • bug #48085 Tell about messenger:consume invalid limit options (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.16(Nov 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v5.4.15...v5.4.16)

    • bug #48179 Support completion for bash functions (Chi-teck)
    • bug #48217 Improve error message when shell is not detected in completion command (GromNaN)
    • bug #48210  Fix signal handlers called after event listeners and skip exit (GromNaN)
    • bug #47998 Fix console ProgressBar::override() after manual ProgressBar::cleanup() (maxbeckers)
    • bug #48085 Tell about messenger:consume invalid limit options (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.49(Nov 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v4.4.48...v4.4.49)

    • bug #48085 Tell about messenger:consume invalid limit options (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-RC1(Nov 25, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.2.0-BETA3...v6.2.0-RC1)

    • bug #48179 Support completion for bash functions (Chi-teck)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA3(Nov 19, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.2.0-BETA2...v6.2.0-BETA3)

    • bug #48217 Improve error message when shell is not detected in completion command (GromNaN)
    • bug #48210  Fix signal handlers called after event listeners and skip exit (GromNaN)
    • bug #47998 Fix console ProgressBar::override() after manual ProgressBar::cleanup() (maxbeckers)
    • bug #48085 Tell about messenger:consume invalid limit options (MatTheCat)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA2(Oct 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.2.0-BETA1...v6.2.0-BETA2)

    • bug #47907 Update Application.php (aleksandr-shevchenko)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.7(Oct 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.1.6...v6.1.7)

    • bug #47907 Update Application.php (aleksandr-shevchenko)
    • bug #47883 Fix error output on windows cli (Maximilian.Beckers)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.15(Oct 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.0.14...v6.0.15)

    • bug #47907 Update Application.php (aleksandr-shevchenko)
    • bug #47883 Fix error output on windows cli (Maximilian.Beckers)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.15(Oct 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v5.4.14...v5.4.15)

    • bug #47907 Update Application.php (aleksandr-shevchenko)
    • bug #47883 Fix error output on windows cli (Maximilian.Beckers)
    Source code(tar.gz)
    Source code(zip)
  • v4.4.48(Oct 28, 2022)

    Changelog (https://github.com/symfony/console/compare/v4.4.47...v4.4.48)

    • bug #47907 Update Application.php (aleksandr-shevchenko)
    • bug #47883 Fix error output on windows cli (Maximilian.Beckers)
    Source code(tar.gz)
    Source code(zip)
  • v6.2.0-BETA1(Oct 24, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.1.6...v6.2.0-BETA1)

    • feature #47750 Show available commands in namespace when running namespace as command (wouterj)
    • feature #47730 Ban DateTime from the codebase (WebMamba)
    • feature #47308 Allow limiting the height of a console section (wouterj)
    • feature #47588 Add warning for possibly truncated inputs in QuestionHelper (#47586) (pbek)
    • feature #38996 Remove the default values from setters with a nullable parameter (derrabus, nicolas-grekas)
    • feature #47407 Terminal Color Mode refactoring and force Color Mode (julien-boudry)
    • feature #47062 Don't cut Urls wrapped in SymfonyStyle block (fchris82, GromNaN)
    • feature #46242 Add support for resuming a ProgressBar (yivi)
    • feature #46944 Add Ansi8 (256 color) support, improve true color (Ansi24) support detection (julien-boudry)
    • feature #47018 Zsh shell autocompletion (adhocore, GromNaN)
    • feature #46901 Be explicit about the completion API version (wouterj)
    • feature #46896 Console/SymfonyStyle: Add Multiselect to choice() (julien-boudry)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.6(Oct 12, 2022)

  • v6.0.14(Oct 12, 2022)

  • v5.4.14(Oct 12, 2022)

  • v4.4.47(Oct 12, 2022)

  • v6.1.5(Sep 30, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.1.4...v6.1.5)

    • bug #47463 Make fish completion run in non interactive mode (Seldaek)
    • bug #47394 Make bash completion run in non interactive mode (Seldaek)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.13(Sep 30, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.0.12...v6.0.13)

    • bug #47394 Make bash completion run in non interactive mode (Seldaek)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.13(Sep 30, 2022)

    Changelog (https://github.com/symfony/console/compare/v5.4.12...v5.4.13)

    • bug #47394 Make bash completion run in non interactive mode (Seldaek)
    Source code(tar.gz)
    Source code(zip)
  • v6.1.4(Aug 26, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.1.3...v6.1.4)

    • bug #47372 Fix OutputFormatterStyleStack::getCurrent return type (alamirault)
    • bug #47218 fix dispatch signal event check for compatibility with the contract interface (xabbuh)
    • bug #45333 Fix ConsoleEvents::SIGNAL subscriber dispatch (GwendolenLynch)
    Source code(tar.gz)
    Source code(zip)
  • v6.0.12(Aug 26, 2022)

    Changelog (https://github.com/symfony/console/compare/v6.0.11...v6.0.12)

    • bug #47372 Fix OutputFormatterStyleStack::getCurrent return type (alamirault)
    • bug #47218 fix dispatch signal event check for compatibility with the contract interface (xabbuh)
    • bug #45333 Fix ConsoleEvents::SIGNAL subscriber dispatch (GwendolenLynch)
    Source code(tar.gz)
    Source code(zip)
  • v5.4.12(Aug 26, 2022)

    Changelog (https://github.com/symfony/console/compare/v5.4.11...v5.4.12)

    • bug #47218 fix dispatch signal event check for compatibility with the contract interface (xabbuh)
    • bug #45333 Fix ConsoleEvents::SIGNAL subscriber dispatch (GwendolenLynch)
    Source code(tar.gz)
    Source code(zip)
💥 Collision is a beautiful error reporting tool for command-line applications

Collision was created by, and is maintained by Nuno Maduro, and is a package designed to give you beautiful error reporting when interacting with your

Nuno Maduro 4.2k Jan 5, 2023
A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

Front End Compiler A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies. The minif

Happy Medium 2 Nov 12, 2021
Twitter raffles in the command line, with PHP and minicli

Rafflebird Rafflebird is a highly experimental CLI application for giveaways / raffles on Twitter, built in PHP with Minicli. Disclaimer: The recent s

Erika Heidi 33 Nov 16, 2022
Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt

EasyEngine v4 EasyEngine makes it greatly easy to manage nginx, a fast web-server software that consumes little memory when handling increasing volume

EasyEngine 2k Jan 4, 2023
Provides the equivalent of request ( Context ) and response ( Stdio ) objects for the command line interface

Provides the equivalent of request ( Context ) and response ( Stdio ) objects for the command line interface, including Getopt support, and an independent Help object for describing commands.

Aura for PHP 103 Sep 28, 2022
Lovely PHP wrapper for using the command-line

ShellWrap What is it? It's a beautiful way to use powerful Linux/Unix tools in PHP. Easily and logically pipe commands together, capture errors as PHP

James Hall 745 Dec 30, 2022
A PHP library for command-line argument processing

GetOpt.PHP GetOpt.PHP is a library for command-line argument processing. It supports PHP version 5.4 and above. Releases For an overview of the releas

null 324 Dec 8, 2022
Command-Line Interface tools

Aura.Cli Provides the equivalent of request ( Context ) and response ( Stdio ) objects for the command line interface, including Getopt support, and a

Aura for PHP 102 Dec 31, 2022
Another Command Line Argument Parser

Optparse — Another Command Line Argument Parser Install 1. Get composer. 2. Put this into your local composer.json: { "require": { "chh/optparse

Christoph Hochstrasser 18 Nov 1, 2019
👨🏻‍🚀 A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. 🚀

Alpine Day Schedule a command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, instal

Nuno Maduro 11 Jun 10, 2021
PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal.

PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal. ??

Nuno Maduro 32 Dec 26, 2022
Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check. Installation / Usage Requires PHP 8.0+ First, install Patr

Nuno Maduro 237 Nov 14, 2022
A command line code generator for Drupal.

Drupal Code Generator A command line code generator for Drupal. Installation Download the latest stable release of the code generator.

Ivan 227 Dec 14, 2022
A PHP command line tool used to install shlink

Shlink installer A PHP command line tool used to install shlink. Installation Install this tool using composer.

null 8 Nov 3, 2022
Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone.

Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, install: c

Nuno Maduro 101 Sep 16, 2022
Generic PHP command line flags parse library

PHP Flag Generic PHP command line flags parse library Features Generic CLI options and arguments parser. Support set value data type(int,string,bool,a

PHP Toolkit 23 Nov 13, 2022
A simple command-line tool whose aim is to facilitate the continous delivery of PHP apps

Deployer Simple command-line tool that aims to facilitate the continous delivery of PHP apps, particularly Laravel apps. Imagine you want to update yo

Fernando Bevilacqua 4 Sep 8, 2021
🍃 In short, it's like Tailwind CSS, but for the PHP command-line applications.

Termwind Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API. In short, it's like Tailwind CSS

Nuno Maduro 1.8k Dec 30, 2022