Download the PHP package phalapi/cli without Composer
On this page you can find all versions of the php package phalapi/cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package cli
Short Description PhalApi 2.x 扩展类库 - CLI命令行,可用于开发命令行应用,基于GetOpt,主要作用是将命令参数进行解析和处理。
License GPL-3.0+
Homepage https://www.phalapi.net/
Informations about the package cli
CLI扩展类库
此类库可用于开发命令行应用,基于GetOpt.PHP,主要作用是将命令参数进行解析和处理。
安装
执行 ,或 在项目的composer.json文件中,添加:
配置好后,再执行更新操作即可。
编写你的命令行入口文件
创建以下的CLI入口文件,保存到:bash $ ./bin/phalapi-cli Usage: ./bin/phalapi-cli [options] [operands]
Options:
-s, --service
Service:
缺少service参数,请使用 -s 或 --service 指定需要调用的API接口。
$ ./bin/phalapi-cli -s App.Hello.World
Service: App.Hello.World { "ret": 200, "data": { "content": "Hello World!" }, "msg": "" } -hbash $ ./bin/phalapi-cli -s App.Examples_Rule.SexEnum -h Usage: ./bin/phalapi-cli [options] [operands]
Options:
-s, --service
Options:
-s, --service
Service: App.User_User.Register 缺少username参数,请使用 --username 指定:账号,账号需要唯一 PhalApi\CLI\Lite::getHelpText($text)./bin/phalapi-clibash $ php ./bin/phalapi-cli Usage: ./bin/phalapi-cli [options] [operands]
Options:
-s, --service
--- 自定义的帮助说明 ---
Service: 缺少service参数,请使用 -s 或 --service 指定需要调用的API接口 PhalApi\CLI\Lite::getServiceList() array( 编号 => array('service接口服务名称', '功能说明'), ) bash $ ./bin/phalapi-cli Usage: ./bin/phalapi-cli [options] [operands]
Options:
-s, --service
--- 自定义的帮助说明 ---
Service: 1) App.Hello.World 演示接口
缺少service参数,请使用 -s 或 --service 指定需要调用的API接口。 bash $ ./bin/phalapi-cli -s 1
Service: App.Hello.World { "ret": 200, "data": { "content": "Hello World!" }, "msg": "" }
// 完成命令行参数获取后的操作,方便追加公共参数
protected function afterGetOptions($options) {
return $options;
}
## 参考和依赖
phalapi/cli使用了[GetOpt.PHP](https://github.com/getopt-php/getopt-php)进行命令参数的获取的解析。
关于更多关于php处理命令行参数,或者需要定制自己和升级命令行处理的参数格式,可以参考[GetOpt.php的官方文档-Example](http://getopt-php.github.io/getopt-php/example.html)。