Download the PHP package yeriomin/getopt without Composer

On this page you can find all versions of the php package yeriomin/getopt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package getopt

getopt

Latest Version Build Status Scrutinizer Code Quality SensioLabsInsight

A small PHP getopt helper/library. Provides a customizable input parameter interpretation and usage message generation.

Usage

$ composer require yeriomin/getopt

Features

  1. Obviously it parses command line options. Uses $_SERVER['argv'].
  2. Short and long options, arguments.
  3. Short options clustering.
  4. Required options.
  5. -- argument separator.
  6. Usage message generation.

Detailed usage

Arguments and options

Lets see how getopt deals with the following input:

$ php somescript.php arg1 --option1 value1 -o value2 -abc -- --option3 value3

Getting option value

getArguments()

Returns an array of arguments. For the above example returns:

getOptionsLong()

Returns an array of long options. For the above example returns:

getOptionsShort()

Returns an array of short options. For the above example returns:

Defining options

If you just want to get console arguments, you just need the three methods covered in the previous section. However giving getopt definitions of options you expect lets you define required options and get a usage message.

addOptionDefinition()

Doing this defines -c|--config option. Providing -c populates --config and vice versa.

Required options

Forth argument in the OptionDefinition constructor makes option required. You can do the same with $optionDefinition->setRequired(). If any required option is not provided, getopt will throw an exception when getArguments, getOptionsShort or getOptionsLong are called.

getUsageMessage()

This method lets you get a usage message based on the options you have defined. Is looks somewhat like a man page.

Trying to run this script with no arguments would give us the following message:


All versions of getopt with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yeriomin/getopt contains the following files

Loading the files please wait ....