在线看片18_亚洲性吧_在线污_神马午夜达达兔_奇米色网_在线免费看污

自定義命令

EasySwoole 3.3.x 默認自帶有 5 個命令,如下所示:

php easyswoole.php help  命令幫助
php easyswoole.php install 安裝(需要在./vendor/easyswoole/easyswoole/bin/easyswoole 文件中調用)
php easyswoole.php start  啟動
php easyswoole.php stop   停止(需要守護進程)
php easyswoole.php reload  熱重啟(需要守護進程)

默認命令詳細內容可查看 服務管理

定義命令

通過實現 \EasySwoole\EasySwoole\Command\CommandInterface 接口,用戶可自定義命令:

需要實現的接口如下:

<?php

namespace EasySwoole\EasySwoole\Command;

interface CommandInterface
{
    public function commandName():string;
    public function exec(array $args):?string ;
    public function help(array $args):?string ;
}

新建文件 App/Command/Test.php:

<?php
namespace App\Command;

use EasySwoole\EasySwoole\Command\CommandInterface;
use EasySwoole\EasySwoole\Command\Utility;

class Test implements CommandInterface
{
    public function commandName(): string
    {
        return 'test';
    }

    public function exec(array $args): ?string
    {
        //打印參數,打印測試值
        var_dump($args);
        echo 'test'.PHP_EOL;
        return null;
    }

    public function help(array $args): ?string
    {
        //輸出logo
        $logo = Utility::easySwooleLog();
        return $logo."this is test";
    }
}

注冊自定義命令

查看 boostrap事件

在項目根目錄中新增 bootstrap.php 文件,添加內容如下,實現注冊自定義命令:

<?php

\EasySwoole\EasySwoole\Command\CommandContainer::getInstance()->set(new \App\Command\Test());

bootstrap3.2.5 新增的事件,它允許用戶在框架初始化之前執行自定義事件。

執行命令及執行結果

$ php easyswoole.php test
array(0) {
}
test

$ php easyswoole.php test 123 456
array(2) {
  [0]=>
  string(3) "123"
  [1]=>
  string(3) "456"
}
test

$ php easyswoole.php help test
  ______                          _____                              _
 |  ____|                        / ____|                            | |
 | |__      __ _   ___   _   _  | (___   __      __   ___     ___   | |   ___
 |  __|    / _` | / __| | | | |  \___ \  \ \ /\ / /  / _ \   / _ \  | |  / _ \
 | |____  | (_| | \__ \ | |_| |  ____) |  \ V  V /  | (_) | | (_) | | | |  __/
 |______|  \__,_| |___/  \__, | |_____/    \_/\_/    \___/   \___/  |_|  \___|
                          __/ |
                         |___/
this is test
主站蜘蛛池模板: 一级片一级片一级片 | 欧美日韩精品久久久 | 91精品福利 | 麻豆精品一区 | 91社在线播放 | 日本视频www | 超碰人人人人 | 黑丝av在线 | 亚洲综合区 | 亚洲免费中文字幕 | 在线免费观看毛片 | 国产精品v欧美精品v日韩 | 亚洲最大成人av | 日本黄页网站免费大全 | 黄色一级视频免费看 | 中文字幕网站在线观看 | 91国内视频| 成人免费大片黄在线播放 | jizz日本在线观看 | 日韩av在线播 | 日韩久久高清 | 全部免费毛片在线播放高潮 | 激情网色 | 日韩中文字幕亚洲 | 色无极亚洲影院 | 久久精品99国产精 | 欧美视频不卡 | 日韩大片免费 | aa黄色大片 | 狠狠干五月天 | 亚洲国产精 | 日韩深夜| 久久婷婷六月 | 日韩精品第一页 | 丁香在线视频 | 久久久免费高清视频 | 最近中文字幕在线观看视频 | 毛片在哪看| 黄色三级在线视频 | 黄色ww | 91成人在线播放 |