samejack/php-argv

PHP CLI arguments parse.

Maintainers

👁 samejack

Package info

github.com/samejack/php-argv

pkg:composer/samejack/php-argv

Statistics

Installs: 95 659

Dependents: 6

Suggesters: 0

Stars: 26

Open Issues: 0

1.0.3 2020-07-15 12:28 UTC

Requires

  • php: >=5.3.0

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

Apache-2.0 0551f0f7fd38a5e9dcb316d5cc9028cdd62b21ac

  • SJ <sj.woop@toright.com>

phpcli

This package is auto-updated.

Last update: 2026-06-17 15:39:27 UTC


README

👁 Latest Stable Version
👁 Build Status
👁 Coverage Status
👁 License

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