samejack / php-argv
PHP CLI arguments parse.
Installs: 67 574
Dependents: 7
Suggesters: 0
Security: 0
Stars: 25
Watchers: 3
Forks: 5
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- php-coveralls/php-coveralls: *@stable
- phpunit/phpunit: ~4.8|~5.7
- squizlabs/php_codesniffer: *@stable
This package is auto-updated.
Last update: 2024-10-17 12:06:50 UTC
README
PHP CLI (command-line interface) argurments parser. PHP-Argv can parse rich pattern, such as the follows
Install by composer
composer require samejack/php-argv
CLI Example
$ ./example/bin-cli -h 127.0.0.1 -u=user -p passwd --debug --max-size=3 test
Array
(
[h] => 127.0.0.1
[u] => user
[p] => passwd
[debug] => 1
[max-size] => 3
[test] => 1
)
PHP Example
<?php require_once(__DIR__ . '/vendor/autoload.php'); $argvParser = new \samejack\PHP\ArgvParser(); $string = '-h 127.0.0.1 -u=user -p passwd --debug --max-size=3 test'; print_r($argvParser->parseConfigs($string));
Output:
Array ( [h] => 127.0.0.1 [u] => user [p] => passwd [debug] => 1 [max-size] => 3 [test] => 1 )
License
Apache License 2.0