学习路之TP6 --重写vendor目录下的文件(新建命令)

@[TOC](学习路之TP6 --重写vendor目录下的文件(新建命令))

一、新建命令文件

bash 复制代码
php think make:command CustomWorker

二、修改

复制vendor\topthink\think-worker\src\command\Server.php 内容到app\command\CustomWorker.php

修改继承类:class CustomWorker extends \think\worker\command\Server

重写要更改的方法:这里是execute这个方法,具体看个人需求

bash 复制代码
<?php
namespace app\command;

use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\facade\App;
use think\facade\Config;
use think\worker\Server as WorkerServer;
use Workerman\Worker;

/**
 * Worker Server 命令行类
 */
class CustomWorker extends \think\worker\command\Server
{
 
    public function execute(Input $input, Output $output)
    {
        $action = $input->getArgument('action');

        $output->writeln('Starting Workerman server...CustomWorkerCustomWorkerCustomWorkerCustomWorker');
        return ;

    }
}

三、运行效果

php think custom-server

相关推荐
百分百题库APP1 小时前
江苏安全员 A 证 “安全生产管理” 核心考点
学习·考试·题库·考证
霜绛5 小时前
Unity笔记(六)——Mathf、三角函数、坐标系、向量
笔记·学习·unity·游戏引擎
long3166 小时前
代理设计模式
java·学习·程序人生·设计模式·代理模式
MThinker7 小时前
14.examples\01-Micropython-Basics\demo_yield.py 加强版
python·学习·智能硬件·micropython·canmv·k230
月盈缺7 小时前
学习嵌入式的第二十五天——哈希表和内核链表
学习·链表·散列表
好奇龙猫8 小时前
日语学习-日语知识点小记-构建基础-JLPT-N3阶段(19):文法复习+单词第7回1
学习
ts码农8 小时前
blazor 学习笔记--vscode debug
笔记·vscode·学习
牛奶yu茶9 小时前
Python学习笔记之(二)变量和简单的数据类型
笔记·python·学习
thginWalker10 小时前
18 继续学习
学习
梦幻精灵_cq10 小时前
《用餐》,午餐食堂即景小诗分享(手机/小视频/光盘/养生)
学习