Download the PHP package hongye/rc-cmd without Composer
On this page you can find all versions of the php package hongye/rc-cmd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download hongye/rc-cmd
More information about hongye/rc-cmd
Files in hongye/rc-cmd
Download hongye/rc-cmd
More information about hongye/rc-cmd
Files in hongye/rc-cmd
Vendor hongye
Package rc-cmd
Short Description A short description of what your package does
License
Package rc-cmd
Short Description A short description of what your package does
License
Please rate this library. Is it a good library?
Informations about the package rc-cmd
PHP 命令行脚本框架库
背景
部分业务使用PHP编写运维脚本, 但PHP缺乏一个易用的命令行程序开发库. 此框架的基于注解的方式支持填空式的快速开发命令行脚本. 并提供统一的日志|参数解析|控制台格式输出|帮助文档能力.
使用方法
引入依赖
在运维脚本项目中引入依赖.
编写运维工具类
创建一个工具类比如SampleTool, 并继承\Ruochen\Tools\CommandTool
, 分别在类和方法上加上如下注解. 最终通过调用 SampleTool::getInstance()->process();
使类文件变为脚本, 并为类文件加上可执行权限.
框架实现了一些易用的注解,基于注解快速定义命令、命令选项、命令参数. 由于PHP本身并不支持注解, 故注解需要添加在文档注释中.
可以为IDE添加注解支持
- Eclipse http://symfony.dubture.com/
- PhpStorm http://plugins.jetbrains.com/plugin/7320-php-annotations
@\Ruochen\Annotations\Command
此注解为工具定义一个命令,属性如下
- name 可选值,如不设值,则命令名称为方法名
- desc 可选值,命令的说明
@\Ruochen\Annotations\Operand
此注解为命令定义一个操作数,属性如下
- name 必须,操作数名称
- mode 模式,枚举值{"required","multiple","optional"}
- required 表示此命令必须有此操作数
- multiple 表示此操作数是多个值
- optional 表示此操作数可选
@\Ruochen\Annotations\Option
此注解为命令定义一个选项。此注解可以注解在class或者command method上,如果注解在class上,则在所有command method上都可以访问到
- short 必须,选项缩写
- long 长选项
- mode 模式,枚举值
- noArg 表示无参数,常用语开关选项
- requiredArg 选项必须有参数 如:-f /var/mysqld.sock || --file=/var/mysqld.sock
- optionalArg 选项可选参数
- multipleArg 选项有多个参数
示例
命令工具文件 sample
命令行提示
运行依赖
- php >= 7.0
- mbstring
- mcrypt
- hash
- composer
All versions of rc-cmd with dependencies
PHP Build Version
Package Version
Requires
php Version
^7.0
nette/utils Version ^2.4
jbzoo/utils Version ^2.2
hassankhan/config Version ^0.11.2
monolog/monolog Version ^1.23
symfony/yaml Version 3.3.5
ulrichsg/getopt-php Version ^3.0
doctrine/annotations Version 1.4.0
league/climate Version ^3.2
vlucas/phpdotenv Version ^2.4
nette/utils Version ^2.4
jbzoo/utils Version ^2.2
hassankhan/config Version ^0.11.2
monolog/monolog Version ^1.23
symfony/yaml Version 3.3.5
ulrichsg/getopt-php Version ^3.0
doctrine/annotations Version 1.4.0
league/climate Version ^3.2
vlucas/phpdotenv Version ^2.4
The package hongye/rc-cmd contains the following files
Loading the files please wait ....