uniondrug/console

Uniondrug Console Component for uniondrug/framework

2.3.1 2020-07-13 08:23 UTC

This package is auto-updated.

Last update: 2024-11-13 18:13:51 UTC


README

安装

composer requre uniondrug/console

使用

$ php console
   __  __      _             ____                  
  / / / /___  (_)___  ____  / __ \_______  ______ _
 / / / / __ \/ / __ \/ __ \/ / / / ___/ / / / __ `/
/ /_/ / / / / / /_/ / / / / /_/ / /  / /_/ / /_/ / 
\____/_/ /_/_/\____/_/ /_/_____/_/   \__,_/\__, /  
                                          /____/   Console 1.0.0

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env[=ENV]       The environment the command should run under. [default: "development"]
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  config      列出所有配置文件
  help        Displays help for a command
  list        Lists commands

命令

默认命令

config 列出所有配置文件信息。使用如下:

$ php console config -e production
+-----------------------------------+----------------------+
| Key                               | Value                |
+-----------------------------------+----------------------+
| key.k1.k2                         | value                |
+-----------------------------------+----------------------+

自定义命令

在项目app\Commands目录下,创建命令,默认命名空间是App\Commands,命令类必须以Command结尾,继承UniondrugConsole\Command.

比如:

namespace App\Commands;

use Uniondrug\Console\Command;

class LocalCommand extends Command
{
    public function configure()
    {
        $this->setName('local:name');
    }

    public function handle()
    {
        $this->line("Hello world");
    }
}