学习路之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

相关推荐
小一亿8 分钟前
【0基础PS】Photoshop (PS) 理论知识
学习·平面·adobe·信息可视化·photoshop
慕y2741 小时前
Java学习第九十一部分——OkHttp
java·开发语言·学习
LiuYaoheng2 小时前
【Android】使用 Intent 传递对象的两种序列化方式
android·java·笔记·学习
九章数学体系2 小时前
九章数学体系:打破“吃苦悖论”,重构学习真谛
数据结构·学习·算法·数学建模·拓扑学
饮浊酒4 小时前
初始C语言---第四讲(数组)
c语言·学习
楞伽sr4 小时前
STM32学习记录--Day6
stm32·嵌入式硬件·学习
【上下求索】13 小时前
学习笔记090——Ubuntu 中 UFW 防火墙的使用
笔记·学习·ubuntu
hhj123k14 小时前
渗透作业3
网络·学习
心一信息14 小时前
HCIE学习之路:一个NAT实验
学习·计算机网络·智能路由器
蓝桉80216 小时前
opencv学习(视频读取)
人工智能·opencv·学习