承接 friendsofhyperf/closure-command 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

friendsofhyperf/closure-command

最新稳定版本:v3.1.0

Composer 安装命令:

composer require friendsofhyperf/closure-command

包简介

The closure command component for Hyperf.

关键字:

README 文档

README

Latest Stable Version Total Downloads License

The closure command component for Hyperf.

⚠️ This component is deprecated, please use hyperf/command instead.

Installation

composer require friendsofhyperf/closure-command

Publish

php bin/hyperf.php vendor:publish friendsofhyperf/closure-command

Usage

  • Define ClosureCommand
// config/console.php

use FriendsOfHyperf\ClosureCommand\Console;
use FriendsOfHyperf\ClosureCommand\Inspiring;

Console::command('inspire', function () {
    $this->comment(Inspiring::quote());
})->describe('Display an inspiring quote');

Console::command('foo:bar', function() {
    $this->info('Command foo:bar executed.');
})->describe('Description of command foo::bar');
  • Define AnnotationCommand
<?php

namespace App\Service;

use FriendsOfHyperf\ClosureCommand\Annotation\Command;
use FriendsOfHyperf\ClosureCommand\Output;
use Hyperf\Di\Annotation\Inject;

#[Command(signature: 'foo:bar1', handle: 'bar1', description: 'The description of foo:bar1 command.')]
#[Command(signature: 'foo', description: 'The description of foo command.')]
class FooService
{
    use \Hyperf\Command\Concerns\InteractsWithIO;

    #[Command(signature: 'foo:bar {--bar=1 : Bar Value}', description: 'The description of foo:bar command.')]
    public function bar($bar)
    {
        $this->output?->info('Bar Value: ' . $bar);

        return $bar;
    }

    public function bar1()
    {
        $this->output?->info(__METHOD__);
    }

    public function handle()
    {
        $this->output?->info(__METHOD__);
    }
}

Run php bin/hyperf.php

foo
  foo:bar                   The description of foo:bar command.
  foo:bar1                  The description of foo:bar1 command.

Donate

If you like them, Buy me a cup of coffee. Alipay | WeChat

Contact

License

MIT

统计信息

  • 总下载量: 15.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-03