Download the PHP package nowise/uup-application-options without Composer
On this page you can find all versions of the php package nowise/uup-application-options. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nowise/uup-application-options
More information about nowise/uup-application-options
Files in nowise/uup-application-options
Package uup-application-options
Short Description Uniform CLI command line and HTTP request options.
License Apache-2.0
Homepage https://nowise.se/oss/uup/application-options
Informations about the package uup-application-options
UUP-APPLICATION-OPTIONS
Supports transparent/uniform handling of runtime options from CLI command and HTTP request.
This package supports short/long options, other options and reading password from terminal (masked echo output). For HTTP request options, an optional filter can be applied.
USAGE:
In your command action class, define a method that checks whether to return command line options (CLI) or from request option (HTTP).
Calling getApplicationOptions
will provide uniform access to application options, whether these come from command line
or the HTTP request. From your application perspective the origin of options is transparent.
From within the application, a number of convenient methods can be used for checking if options was passed and retrieve them with type safety.
A number of other getters exist, for example for boolean, float and integer values. These takes a second default value that is returned of option is missing.
ORIGIN:
If origin matters, it can be checked:
OPTION ALIAS:
For command line options, the default behavior is to return options by stripping leading dashes ('-'). To support short command options mapped to long options, pass a mapping array.
These two short option will now be an alias for their equivalent long option. Some builtin aliases are implicit handled for command line options. These short options are:
- -h => help
- -V => version
- -d => debug
- -v => verbose
- -q => quiet
These are processed before user defined mappings, making it possible to easily redefine the builtin mapping.
OPTION VALUES:
Option values are any value after the equal character ('='). For options without a value, the option key will be read having boolean true as its value.
DASHES:
Processing of command line options (CLI) will strip leading dashes and use the remaining string as the command option key.
OPTION FILTERING:
Command line options are considered safe. For HTTP request, it's possible to pass an array of sanitation filter to be applied.
The default behavior is to not filter HTTP request options. For larger applications, some framework for purify HTML
input might be used that could be wrapped in a class that implements the FilterInterface
and used instead of passing
an instance of the HttpRequestFilter
class.
BOOLEANS:
Special treatment of boolean options are implemented. For example, option values "1", "true", "on" and "yes" yields true. Analogous "0", "false", "off" and "no" yields false.
Example: Call getBoolean
to have the value for filter option evaluated as boolean.