simonepm / argumentor
简单易用的PHP库,用于从命令行传递参数和选项到PHP命令脚本。
v1.0
2018-10-28 20:59 UTC
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2024-09-29 05:02:12 UTC
README
简单易用的PHP库,用于从命令行传递参数和选项到PHP脚本。
安装
composer require simonepm/argumentor
用法
php example.php testArgument -o testOption
示例
<?php require_once "vendor/autoload.php"; use Simonepm\Argumentor\Command; use Simonepm\Argumentor\Argument; use Simonepm\Argumentor\Option; $command = new Command(); $command->RegisterArgument("argument"); $command->RegisterOption("option", "o"); $command->Exec(function(Argument $argument, Option $option) { echo $argument->Get("argument") . PHP_EOL; // "testArgument\n" echo $option->Get("option") . PHP_EOL; // "testOption\n" }); ?>