rareloop / hatchet

此包最新版本(v1.1.2)没有可用的许可证信息。

v1.1.2 2023-04-05 14:08 UTC

This package is auto-updated.

Last update: 2024-09-05 17:12:24 UTC


README

CI Coveralls

安装

composer require rareloop/hatchet

安装完成后,您需要将 hatchet 文件复制到您的 Lumberjack 主题目录中。

假设您在 Bedrock 内部使用 Lumberjack。如果不是,您可能需要修改 hatchet 文件中的路径。

基本用法

现在您可以从 Lumberjack 主题目录中访问 Hatchet CLI。

显示可用命令

php hatchet list

运行命令

对于名为 test:command 的给定命令,您将运行以下内容

php hatchet test:command

获取有关命令的额外帮助

对于名为 test:command 的给定命令,您将运行以下内容

php hatchet help test:command

添加命令

要将额外命令添加到 Hatchet,请将它们添加到 config/hatchet.php(如果不存在则创建该文件)。

// config/hatchet.php

return [
    'commands' => [
        MyCommand::class,
    ],
];

编写命令

创建 Rareloop\Hatchet\Commands\Command 的子类

namespace MyNamespace;

use Rareloop\Hatchet\Commands\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ControllerMake extends Command
{
    protected $signature = 'test:command {paramName : The description of the parameter}';

    protected $description = 'A description of the command';

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        // Command implementation
    }
}

Hatchet 使用与 Laravel 相同的 $signature 语法,有关更多信息请参阅此处

Hatchet Command 是 Symfony 的 Command 对象的子类,有关如何实现 execute() 函数的更多信息请参阅此处