A PHP library for command-line argument processing

Overview

GetOpt.PHP

Build Status Coverage Status Latest Stable Version Total Downloads License

GetOpt.PHP is a library for command-line argument processing. It supports PHP version 7.1 and above.

Releases

For an overview of the releases with a changelog please have look here: https://github.com/getopt-php/getopt-php/releases

Features

  • Supports both short (e.g. -v) and long (e.g. --version) options
  • Option aliasing, ie. an option can have both a long and a short version
  • Cumulative short options (e.g. -vvv)
  • Two alternative notations for long options with arguments: --option value and --option=value
  • Collapsed short options (e.g. -abc instead of -a -b -c), also with an argument for the last option (e.g. -ab 1 instead of -a -b 1)
  • Two alternative notations for short options with arguments: -o value and -ovalue
  • Quoted arguments (e.g. --path "/some path/with spaces") for string processing
  • Options with multiple arguments (e.g. --domain example.org --domain example.com)
  • Operand (positional arguments) specification, validation and limitation
  • Command routing with specified options and operands
  • Help text generation
  • Default argument values
  • Argument validation

Upgrading

If you are still using a legacy version of GetOpt.PHP, please consider upgrading to version 3.

Only a few adjustments to your code are required to benefit from a lot of improvements. Refer to the upgrade guide for details.

Documentation

License

GetOpt.PHP is published under the MIT License.

Comments
  • Improved help rendering.

    Improved help rendering.

    Improved synopsis rendering. Improved operands rendering. Reduced clutter. Reduced the number of assumptions in rendering. Removed duplicates. Fixed failing tests. Seriously, why do you use PHP_EOL in message and then suddenly compare to plain \n in test?

    opened by AnrDaemon 16
  • Add custom validation error messages

    Add custom validation error messages

    Hi,

    As proposed in #112 I've added the ability to specify custom validation error messages. I've introduced a new Validator class, and gathered the validation related features in a new WithValidator trait. Kept Argument::hasValidation() for backward compatibility (because it is public...), and marked it as deprecated. No BC change has been introduced, tests and CS ok. Updated documentation and Changelog accordingly.

    Note: I think the Invalid exception should be thrown in the Validation, rather in the Operand::setValue() and Option::setValue() methods. The custom message could be defined in the validation when sending the exception. Unfortunately it would make backward compatibility harder to maintain (we would have to handle validation which return false, which means much code just for that). Maybe in 4.0...

    opened by Arcesilas 16
  • Changed Command API to use 'get' verb for accessor methods

    Changed Command API to use 'get' verb for accessor methods

    For the next major release, because method names should always start with a verb. There may be other classes in need of similar refactoring but this seemed like a good place to start.

    opened by Bilge 12
  • A lot of warnings in travis for newer php versions

    A lot of warnings in travis for newer php versions

    The problem is that newer versions are not working on the old php versions - we are staying somehow at a point where it would be the easiest solution to just split up the development with a v3 branch and a new v4 that is only compatible with php 7.1 (I guess will be the matching point where all libraries work on all new versions).

    Another option would be to upgrade the packages only in travis (split the jobs to use different versions (with composer require phpunit:8.* for example).

    Two dependencies are at fault: PHPUnit and PHP Code Sniffer.

    PHPUnit starts spitting deprecated issues with 7.2 and PHP Code Sniffer with 7.4. I guess it is worth giving it a try with the latest versions of both dependencies in 7.4 and see how it reacts, not sure if the source will have to be edited to do so though. What do you think of doing this in a follow up PR to unblock this one?

    Originally posted by @PierrickVoulet in https://github.com/getopt-php/getopt-php/pull/162#issuecomment-657585452

    opened by tflori 9
  • Multiple passes through GetOpt::process() yields strange results

    Multiple passes through GetOpt::process() yields strange results

    My app can read an INI-style text file for default settings, as well as parsing command line parameters through GetOpt. The order of precedence I want is "default value"->"INI value"->"CL value". However, the option for which config file to parse is a command line parameter only. In trying to reconcile this logic, I configure GetOpt with all the commands and options, call GetOpt->process() to populate the values, then read the "config-file" option. I pass that value to a routine which reads the INI and sets the value with GetOpt->getOption($key, TRUE)->setValue($value). This works fine, but leaves the INI values in charge. To reinstate the command line parameters, I call GetOpt->process() again.

    I've found that with a command with an operand, the second call to process() assigns the name of the command as the operand's value. For example, on the initial call to process(), I have this command object:

        DisqusImporter\Commands\CreateTablesCommand::__set_state(array(
           'config' => NULL,
           'log' => NULL,
           'name' => 'create-tables',
           'shortDescription' => 'Creates the database schema',
           'longDescription' => 'Runs the SQL necessary to create the database schema.  Requires the name of the file containing the SQL commands.',
           'handler' => 'DisqusImporter\\Commands\\CreateTablesCommand::handle',
           'options' =>
          array (
          ),
           'optionMapping' =>
          array (
          ),
           'operands' =>
          array (
            0 =>
            GetOpt\Operand::__set_state(array(
               'required' => true,
               'description' => NULL,
               'default' => NULL,
               'validation' => NULL,
               'name' => 'sqlfile',
               'multiple' => false,
               'value' => 'init.sql',
               'option' => NULL,
               'validationMessage' => NULL,
            )),
          ),
        )),
    

    After reading the INI, it is the same. After the second call to process(), this is the object:

        DisqusImporter\Commands\CreateTablesCommand::__set_state(array(
           'config' => NULL,
           'log' => NULL,
           'name' => 'create-tables',
           'shortDescription' => 'Creates the database schema',
           'longDescription' => 'Runs the SQL necessary to create the database schema.  Requires the name of the file containing the SQL commands.',
           'handler' => 'DisqusImporter\\Commands\\CreateTablesCommand::handle',
           'options' =>
          array (
          ),
           'optionMapping' =>
          array (
          ),
           'operands' =>
          array (
            0 =>
            GetOpt\Operand::__set_state(array(
               'required' => true,
               'description' => NULL,
               'default' => NULL,
               'validation' => NULL,
               'name' => 'sqlfile',
               'multiple' => false,
               'value' => 'create-tables',
               'option' => NULL,
               'validationMessage' => NULL,
            )),
          ),
        )),
    

    I believe this is a side-effect of the array_merge() in GetOpt::getOperands(), but I haven't traced down there yet. I understand a work-around could be to just discard the original GetOpt object and instantiate a new one, but that seems clumsy.

    opened by routinet 9
  • Being able to pass options after operands

    Being able to pass options after operands

    I am not sure which is the POSIX standard:

    command operand --help: --help parsed as option

    It would be good if the above example could work.

    It is not that hard to implement it, however the CommandLineParser must loop through all the provided options. I can send a PR for it.

    But I would like to know whether not supporting this is a decision made or just implemented this way.

    feature request 
    opened by sagikazarmark 9
  • Unexpected: Option '...' is unknown even if option is defined

    Unexpected: Option '...' is unknown even if option is defined

    I'm currently encountering a weird exception from GetOpt. I defined an option --help (or -h) but every time I insert that option, it throws me an exception of type GetOpt\ArgumentException\Unexpected with the message:

    Option 'help' is unknown in file /var/www/melior/Packages/Library/ulrichsg/getopt-php/src/GetOpt.php on line 161

    When I debug the GetOpt instance right before the process() call, I can see all my defined options and commands but none of them are actually available:

    GetOpt\GetOpt (10) (
        protected 'additionalOperands' -> array (0) []
        protected 'additionalOptions' -> array (0) []
        protected 'command' -> null
        protected 'commands' -> array (2) [
            'melior:core:cache:flush' => GetOpt\Command (7) (
                protected 'handler' -> string (38) "Melior\Core\Commands\CacheFlushCommand"
                protected 'longDescription' -> string (30) "Flushes the application caches"
                protected 'name' -> string (23) "melior:core:cache:flush"
                protected 'operands' -> array (0) []
                protected 'optionMapping' -> array (2) [
                    'f' => GetOpt\Option (6) (
                        private 'argument' -> GetOpt\Argument (7) (
                            protected 'default' -> null
                            protected 'multiple' -> boolean false
                            protected 'name' -> string (3) "arg"
                            protected 'option' -> GetOpt\Option (6) RECURSION
                            protected 'validation' -> null
                            protected 'validationMessage' -> null
                            protected 'value' -> null
                        )
                        private 'description' -> string (22) "Enables force-flushing"
                        private 'long' -> string (5) "force"
                        private 'mode' -> string (6) ":noArg"
                        private 'short' -> string (1) "f"
                        private 'value' -> null
                    )
                    'force' => GetOpt\Option (6) (
                        private 'argument' -> GetOpt\Argument (7) (
                            protected 'default' -> null
                            protected 'multiple' -> boolean false
                            protected 'name' -> string (3) "arg"
                            protected 'option' -> GetOpt\Option (6) RECURSION
                            protected 'validation' -> null
                            protected 'validationMessage' -> null
                            protected 'value' -> null
                        )
                        private 'description' -> string (22) "Enables force-flushing"
                        private 'long' -> string (5) "force"
                        private 'mode' -> string (6) ":noArg"
                        private 'short' -> string (1) "f"
                        private 'value' -> null
                    )
                ]
                protected 'options' -> array (1) [
                    0 => GetOpt\Option (6) (
                        private 'argument' -> GetOpt\Argument (7) (
                            protected 'default' -> null
                            protected 'multiple' -> boolean false
                            protected 'name' -> string (3) "arg"
                            protected 'option' -> GetOpt\Option (6) RECURSION
                            protected 'validation' -> null
                            protected 'validationMessage' -> null
                            protected 'value' -> null
                        )
                        private 'description' -> string (22) "Enables force-flushing"
                        private 'long' -> string (5) "force"
                        private 'mode' -> string (6) ":noArg"
                        private 'short' -> string (1) "f"
                        private 'value' -> null
                    )
                ]
                protected 'shortDescription' -> string (30) "Flushes the application caches"
            )
        ]
        protected 'help' -> null
        protected 'operands' -> array (0) []
        protected 'operandsCount' -> integer 0
        protected 'optionMapping' -> array (2) [
            'h' => GetOpt\Option (6) (
                private 'argument' -> GetOpt\Argument (7) (
                    protected 'default' -> null
                    protected 'multiple' -> boolean false
                    protected 'name' -> string (10) "noArgument"
                    protected 'option' -> GetOpt\Option (6) RECURSION
                    protected 'validation' -> null
                    protected 'validationMessage' -> null
                    protected 'value' -> null
                )
                private 'description' -> string (47) "Displays help for the CLI or the given command."
                private 'long' -> string (4) "help"
                private 'mode' -> string (6) ":noArg"
                private 'short' -> string (1) "h"
                private 'value' -> null
            )
            'help' => GetOpt\Option (6) (
                private 'argument' -> GetOpt\Argument (7) (
                    protected 'default' -> null
                    protected 'multiple' -> boolean false
                    protected 'name' -> string (10) "noArgument"
                    protected 'option' -> GetOpt\Option (6) RECURSION
                    protected 'validation' -> null
                    protected 'validationMessage' -> null
                    protected 'value' -> null
                )
                private 'description' -> string (47) "Displays help for the CLI or the given command."
                private 'long' -> string (4) "help"
                private 'mode' -> string (6) ":noArg"
                private 'short' -> string (1) "h"
                private 'value' -> null
            )
        ]
        protected 'options' -> array (1) [
            0 => GetOpt\Option (6) (
                private 'argument' -> GetOpt\Argument (7) (
                    protected 'default' -> null
                    protected 'multiple' -> boolean false
                    protected 'name' -> string (10) "noArgument"
                    protected 'option' -> GetOpt\Option (6) RECURSION
                    protected 'validation' -> null
                    protected 'validationMessage' -> null
                    protected 'value' -> null
                )
                private 'description' -> string (47) "Displays help for the CLI or the given command."
                private 'long' -> string (4) "help"
                private 'mode' -> string (6) ":noArg"
                private 'short' -> string (1) "h"
                private 'value' -> null
            )
        ]
        protected 'settings' -> array (3) [
            'strictOptions' => boolean true
            'strictOperands' => boolean false
            'scriptName' => string (8) "./melior"
        ]
    )
    

    The terminal always only shows up this notice:

    Usage: ./melior [operands]

    Is this somehow a bug or am I missing something that breaks my implementation? If further information is needed, I'll provide it as soon as possible. Thanks in advance for your help, Max

    opened by MCStreetguy 8
  • Explicit Options

    Explicit Options

    I'd like to see a way to enable explicit options, meaning either option "x" can be passed as an option, but option "y" would not be allowed or vice-versa (with one possibly being the default).
    A real-world example might be: script.php --read myfile.txt or script.php --write myfile.txt "test data" The idea is that both options cannot coexist ahd either an Exception would be thrown or it would default to one. It could even be expanded to multiple arguments or operands.

    Any thoughts?

    feature request on hold 
    opened by patinthehat 8
  • Error Reporting is Atrocious

    Error Reporting is Atrocious

    Hi,

    I am trying to use your library in a new project and have used it successfully before. This time around, I am getting an obscure error In GetOpt.php line 288: "Illegal offset type in isset or empty"

    As you can tell, this error is useless. I even tried debugging your code, and well, lets just say that its a good thing that you maintain this thing. For Example, WTF? Seriously.

        public function process(GetOpt $getopt, callable $setOption, callable $setCommand, callable $addOperand)
        {
            while (($arg = array_shift($this->arguments)) !== null) {
                if ($this->isMeta($arg)) {
                    // everything from here are operands
                    foreach ($this->arguments as $argument) {
                        $addOperand($argument);
                    }
                    break;
                }
    
                if ($this->isValue($arg)) {
                    $operands = $getopt->getOperands();
    
                    if (empty($operands) && $command = $getopt->getCommand($arg)) {
                        $setCommand($command);
                    } else {
                        $addOperand($arg);
                    }
                }
    
                if ($this->isLongOption($arg)) {
                    $setOption($this->longName($arg), function (Option $option = null) use ($arg) {
                        return $this->value($arg, null, $option);
                    });
                    continue;
                }
    
                // the only left is short options
                foreach ($this->shortNames($arg) as $name) {
                    $requestedValue = false;
                    $setOption($name, function (Option $option = null) use ($arg, $name, &$requestedValue) {
                        $requestedValue = true;
                        return $this->value($arg, $name, $option);
                    });
    
                    if ($requestedValue) {
                        // when there is a value it was the last option
                        break;
                    }
                }
            }
            return true;
        }
    

    This function is an incomprehensible mess. There is a reason things like continue & break are discouraged in just about every language along with multiple return statements and goto. I am not going to tell you how to style your code, but please ensure it produces a usable error when something goes wrong so others don't have to look at it.

    Best Wishes.

    opened by kwhat 7
  • Parsing fails on option-arguments beginning with a hyphen

    Parsing fails on option-arguments beginning with a hyphen

    GetOpt doesn't properly support option-arguments that begin with a hyphen. Specifically, it only handles them as expected when they're part of the same word/argument as the option itself:

    % composer require -q ulrichsg/getopt-php
    
    % cat test.php
    <?php
    
    require_once __DIR__ . '/vendor/autoload.php';
    
    $getopt = new \GetOpt\GetOpt([
      (new \GetOpt\Option('f', 'foo', \GetOpt\GetOpt::REQUIRED_ARGUMENT)),
    ]);
    
    try {
      $getopt->parse();
      echo $getopt->getOption('foo'), "\n";
    } catch ( \Exception $e ) {
      echo $e->getMessage(), "\n";
    }
    
    % php test.php -f-1
    -1
    % php test.php -f -1
    Option 'foo' must have a value
    
    % php test.php --foo=-1
    -1
    % php test.php --foo -1
    Option 'foo' must have a value
    

    Not sure if this is intended to catch mistakes or if it's just an oversight, but it's contrary to the way POSIX/GNU-style argument parsers normally work, and it breaks many common use cases like negative numbers ~~and - as a short-hand for stdin/stdout~~. (Edit: Actually it does handle - correctly.)

    If it is deliberate, could there be an option to disable it?

    feature request 
    opened by okdana 7
  • Versions

    Versions

    Hi,

    According to https://secure.php.net/supported-versions.php and https://secure.php.net/eol.php PHP 5.4 is dead since 2 years and 7 months and 5.5 since 1 year, 8 months.

    Concerning 5.6 and 7.0, they only get security fixes and until the end of this year only.

    At the same time, PHPUnit 4.8 is no longer supported, as for PHPUnit 5 for 2 months. PHPUnit 6, which is the oldest version supported (for 1 year from now) only supports PHP >= 7.0

    Maybe it could be worth considering dropping PHP 5.x versions and upgrading dependencies...? A branch for a future version 4 release could be started, which would support PHP >= 7.1 (with PHPUnit 7 and PHP CS 3.2) ? When possible, features could be backported to 3.x (for PHP 5.4 - 5.6), which branch would still be supported for a while, even when 4.0 will be released.

    What do you think?

    Note: I have some free time...

    opened by Arcesilas 7
  • ArgumentException should not be sent immediately

    ArgumentException should not be sent immediately

    Throwing exceptions immediately when an argument is unexpected or missing when processing arguments list prevent from using valuable options like --help or --verbose, as they have not been processed and therefore are not available when handling the exception.

    To observe, just take the example file provided in the documentation and just make this change:

        try {
            $getOpt->process();
        } catch (unexpected | Missing $exception) {
            // catch missing exceptions if help is requested
            if (!$getOpt->getOption('help')) {
                throw $exception;
            } else {
                echo 'Help option provided'.PHP_EOL;
            }
        }
    

    Now call the script with: php example.php -p --help The exception will always be thrown and the text Help option provided will not be displayed, despite we provided the help option.

    Note that this does not happen if we pass the help option first: php example.php --help -p

    To prevent this from happening, exceptions should be stored somewhere (Symfony uses an ExceptionBag if I'm correct). After processing the arguments list is done, the exceptions can then be checked and handled appropriately. This allows to use options to adjust error handling (verbose mode for example).

    I may provide with some PR if you're interested, to have something concrete to discuss.

    opened by Arcesilas 11
Releases(v4.0.3)
  • v4.0.3(Dec 13, 2022)

  • v4.0.2(Mar 11, 2022)

  • v4.0.1(Jan 5, 2022)

  • v4.0.0(Jun 7, 2021)

    Changelog:

    • drop support for php 5.x and add support for php 8
    • run tests on php 7.x and php 8 on gitlab-ci
    • add type declarations for parameters
    • add link to github versions in old changelog
    • fix return type declarations
    Source code(tar.gz)
    Source code(zip)
  • v4.0.0-alpha.1(Feb 18, 2021)

  • v3.4.0(Jul 14, 2020)

    Version 3.4

    This might be the last version 3 version as we might get rid of the php 5.x compatibility.

    Changelog:

    • compaitibly to php 7.4 #161 and #162
    • updated phpdoc comments #159
    • allow command names to have spaces #150
    Source code(tar.gz)
    Source code(zip)
  • v3.3.0(Dec 8, 2019)

  • v3.3.0-rc.1(Sep 9, 2019)

  • 3.2.2(Jan 22, 2019)

  • 3.2.1(Aug 17, 2018)

  • 3.2.0(Jun 3, 2018)

    Changelog

    • add translation system to translate user errors (solves #108)
    • allow custom validation messages (solves #118)
    • add descriptions to operands (solves #125)
    Source code(tar.gz)
    Source code(zip)
  • 3.2.0-alpha.1(May 31, 2018)

    Changelog

    • add translation system to translate user errors (solves #108)
    • allow custom validation messages (solves #118)
    • add descriptions to operands (solves #125)
    Source code(tar.gz)
    Source code(zip)
  • 3.1.3(May 29, 2018)

  • 3.1.2(May 15, 2018)

  • 3.1.1(May 1, 2018)

  • 3.1.0(Nov 25, 2017)

    Changelog:

    • getters for Command, Argument, Option, Operand and GetOpt changed
    • implemented magic getter for easier access to getters
    • removed default templates for help and implemented functionality as methods
    Source code(tar.gz)
    Source code(zip)
  • 3.1.0-alpha.1(Nov 8, 2017)

    This is a pre release for version 3.1. The help is still not adapted and the release has to wait for it.

    Changelog:

    • getters for Command, Argument, Option, Operand and GetOpt changed
    • implemented magic getter for easier access to getters
    • removed default templates for help and implemented functionality as methods
    Source code(tar.gz)
    Source code(zip)
  • 3.0.3(Nov 2, 2017)

  • 3.0.2(Aug 24, 2017)

  • 3.0.1(Aug 23, 2017)

    Changelog

    • fixed: Operand::required() made the operand multiple on second call (solves #84)
    • added Operand::multiple() for sake of consistence
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Aug 18, 2017)

    Many changes have been made. People already using version 2.* will have to change their code on some places. The most important: the class name and the namespace have changed. If you don't want to change everything just change your use-Statement:

    // use ulrichsg\Getopt;
    use GetOpt\GetOpt as Getopt;
    

    Changelog

    Features

    • php 5.3 support dropped (solves #72)
    • moved to neutral namespace GetOpt
    • classname changed to GetOpt
    • second parameter for constructor got array of settings (use GetOpt::SETTING_* constants)
    • argument constants changed to string :*Arg
    • parse options after operands (gnu compatibility; solves #39)
    • added GetOpt::MULTIPLE_ARGUMENT for parameter aggregation (solves #57)
    • implemented Command for kinda routing in console applications (solves #41)
    • implemented Operand for named operands and validation (solves #27)
    • added strict modes for strict operand and parameter matches (default is true for options) (solves #14)
    • added HelpInterface for custom help implementations
    • refactored GetOpt::getHelpText() for better support of other features and customization
    • default help class uses templates

    Bugfixes

    • GetOpt::count() returns the wrong value (solves #70)
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-beta.1(Aug 7, 2017)

    Many changes have been made. People already using version 2.* will have to change their code on some places. The most important: the class name and the namespace have changed. If you don't want to change everything just change your use-Statement:

    // use ulrichsg\Getopt;
    use GetOpt\GetOpt as Getopt;
    

    Changelog:

    Features:

    • php 5.3 support dropped (solves #72)
    • moved to neutral namespace GetOpt
    • classname changed to GetOpt
    • second parameter for constructor got array of settings (use GetOpt::SETTING_* constants)
    • argument constants changed to string :*Arg
    • parse options after operands (gnu compatibility; solves #39)
    • added GetOpt::MULTIPLE_ARGUMENT for parameter aggregation (solves #57)
    • implemented Command for kinda routing in console applications (solves #41)
    • implemented Operand for named operands and validation (solves #27)
    • added strict modes for strict operand and parameter matches (default is true for options) (solves #14)
    • added HelpInterface for custom help implementations
    • refactored GetOpt::getHelpText() for better support of other features and customization
    • default help class uses templates

    Bugfixes:

    • GetOpt::count() returns the wrong value (solves #70)
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-alpha.8(Aug 5, 2017)

  • 3.0.0-alpha.7(Aug 2, 2017)

    Major changes to command interface.

    • added fluent interface for constructor
    • removed descriptions from constructor
    • added setters for name, handler, description and shortDescription
    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-alpha.6(Jul 30, 2017)

    Some slightly changes to the API for Command.

    1. You can now use the OptionParser for commands which enables options from string and from array
    2. The OptionParser is completly static now
    3. You can not have different default modes in different GetOpt instances

    Because the OptionParser is static now the default mode is a public static property too. All instances from GetOpt and Command use the same default mode. For backward compatibility you can still use the SETTING_DEFAULT_MODE for GetOpt.

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0-alpha.3(Jul 26, 2017)

    Many changes have been made. People already using version 2.* will have to change their code on some places. The most important: the class name and the namespace have changed. If you don't want to change everything just change your use-Statement:

    // use ulrichsg\Getopt;
    use GetOpt\GetOpt as Getopt;
    

    Changelog:

    Features:

    • php 5.3 support dropped (solves #72)
    • moved to neutral namespace GetOpt
    • classname changed to GetOpt
    • second parameter for constructor got array of settings (use GetOpt::SETTING_* constants)
    • argument constants changed to string :*Arg
    • parse options after operands (gnu compatibility; solves #39)
    • added GetOpt::MULTIPLE_ARGUMENT for parameter aggregation (solves #57)
    • implemented Command for kinda routing in console applications (solves #41)
    • implemented Operand for named operands and validation (solves #27)
    • added strict modes for strict operand and parameter matches (default is true for options) (solves #14)
    • added HelpInterface for custom help implementations
    • refactored GetOpt::getHelpText() for better support of other features and customization
    • default help class uses templates

    Bugfixes:

    • GetOpt::count() returns the wrong value (solves #70)
    Source code(tar.gz)
    Source code(zip)
  • 2.4.3(Jul 2, 2017)

  • 2.4.2(Jul 1, 2017)

    merged tflori/getopt-php

    Changelog:

    • don't show options when there are no options configured
    • allow arguments in quotes (allows single quote in double quote and vise versa)
    • get script name from argv[0] when parsing arguments from array or string
    • add method to set scriptname manually
    • support for php 7.1
    Source code(tar.gz)
    Source code(zip)
  • 2.3.0(Mar 28, 2015)

    Features

    • Optional argument descriptions (courtesy of @sabl0r)

    Bugfixes

    • Passing a single hyphen as an option value works now (courtesy of @tistre)
    Source code(tar.gz)
    Source code(zip)
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 powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!

CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands

Yo-An Lin 428 Dec 13, 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
BetterWPCLI - a small, zero-dependencies, PHP library that helps you build enterprise WordPress command-line applications.

BetterWPCLI - a small, zero-dependencies, PHP library that helps you build enterprise WordPress command-line applications.

Snicco 5 Oct 7, 2022
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
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
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
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
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
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
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
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
php command line script to DCA crypto from Coinbase Pro

dca.php A simple php script designed to be run via the command line via a cron job. This will connect to coinbase pro and buy the crypto coins specifi

Ben Suffolk 2 Oct 22, 2021
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
👨🏻‍🚀 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
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
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