cliphp / args
Command line arguments
1.0.4
2018-07-06 17:23 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^6.1
- squizlabs/php_codesniffer: 2.*
This package is auto-updated.
Last update: 2025-01-12 20:05:45 UTC
README
Library for command line arguments.
use Cliphp; $args = new Args; // Check for --help flag if ($args->has('help')) { // show help message } // Get limit value $limit = $args->get('limit') ?? 100;
Notes
The global $argv
variable returns the script name (e.g. index.php) as the first value in
the array. This library will shift the script name from the arguments list.
Available Methods
get(string $arg): mixed|null
Returns value of an argument orNULL
if it doesn't exist.has(string $arg): bool
Checks for existence of an argumentall(): array
Get all of the argumentscount(): int
Get count of arguments