hunomina/cli-oop-php
Composer 安装命令:
composer require hunomina/cli-oop-php
包简介
Implementation of CLI classes for PHP7.1 or higher
README 文档
README
Description : Implementation of CLI classes for PHP7.1 or higher.
This class can be used in a php file called by a CLI with input redirection.
Console
The hunomina\Console\Console class allow you to create script that you can use for background tasks, cron tasks...
To instantiate a Console, you have to pass a folder path to the constructor. This path is where your commands locate.
The folder is then sort out and only files will be parsed.
The Console parses all the files and store all class implementing the hunomina\Command\CommandInterface in the $_commands attribute
The execute($params) method allow you to execute commands.
It the parameters match a command, it will execute it.
If it does not, it will return a failure message.
If $params is null, an empty array or equals to "['help']", the console will print all the available commands.
The console will also print a message based on the command success.
CommandInterface
The hunomina\Command\CommandInterface has 3 methods :
- array getCommand() : Return a list of string composing the command
- string getDescription() : Return the string description of the command (used by the help command)
- bool execute() : Logic of the command. Return true on success and false on failure
Examples
See /tests for examples
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2018-10-19