Download the PHP package aidantwoods/betteroptions without Composer

On this page you can find all versions of the php package aidantwoods/betteroptions. 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 betteroptions

BetterOptions

than getopt()

Synopsis

getopt() sucks. Flags (options with no value) are set as false when they are set, options that are unset by the user will cause a key error if you attempt to look them up. If multiple options are specified you are given an array containing them all, regardless of whether you wanted to recieve an array.

There is no way to specify which type you are expecting. If compulsory options are left unspecified by the user, this will prevent other compulsory options from being parsed, (but will not enforce that these options are present). "long" options are specified in an array, while "short" options are specified by concatenating a string...

All this means that in order to accept command line options, lots (and lots) of ugly validation logic must be manually written. And making use of "long" and "short" options creates unnessesary code to special case the configuration of things that aren't functionally different.


Instead, create a data structure file specifying logical (AND, OR, XOR) requirement groups of options, and/or just specify options on their own with no requirements.

I say "data structure file" here because, in theory you can use whatever you like (provided you create an adapter that implements the right interface and register the file extension). The default supported file types are JSON using PHPs native parser, and YAML (if you also install Symfony's YAML parser from require dev in composer.json).

The expected type of an option can be specified, and this is the type you will recieve (or null if not set). Optionally specify a default value (you can still query whether the user set the variable or the default was loaded without having to hard code in a comparison to the default).

If you're not expecting multiple options you won't get an array. If you want to accept multiple options, but can cope with one just fine you can recieve an array with one item in (types like string[], bool[], integer[] are arrays containing a certain type).

You can document your options in the data structure file too, as well as specifying whether you want a 'long' or 'short' (two or one dash) options without changing the structure of specification.

Aliases can also be defined (e.g. --file, -f). You can make as many as you like (though two is almost always sufficient).

You can recieve responses from groups if their logical conditions fail so you don't have to write error messages yourself, and you can even use an auto-generated help screen populated with the description of each option from the data structure file.

Example

Using the command line options configured in the example options.json/options.yaml, and the code in example.php, the following can be achieved:

If we change the type of --foo from string[] to string in options.json/options.yaml, we can instead get

(the first value configured is returned).

If we just call

then the auto-generated response for incompleteness (based on logical groups setup in the data file) is as follows

Using the auto-generated help screen (we have bound this to --help in the example code), we can use:

to get the following


All versions of betteroptions with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 aidantwoods/betteroptions contains the following files

Loading the files please wait ....