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

相关推荐
threelab2 分钟前
18.three官方示例+编辑器+AI快速学习webgl_buffergeometry_points_interleaved
学习·编辑器·webgl
电子云与长程纠缠16 分钟前
UE5中制作动态数字Decal
学习·ue5·编辑器·贴图
h汉堡21 分钟前
C/C++内存管理
java·c语言·开发语言·c++·学习
水水沝淼㵘1 小时前
嵌入式开发学习日志(数据结构--顺序结构单链表)Day19
linux·服务器·c语言·数据结构·学习·算法·排序算法
Wallace Zhang1 小时前
STM32F103_LL库+寄存器学习笔记22 - 基础定时器TIM实现1ms周期回调
笔记·stm32·学习
lichuangcsdn1 小时前
【springcloud学习(dalston.sr1)】项目整体介绍(含源代码)(一)
学习·spring·spring cloud
红衣小蛇妖1 小时前
Python基础学习-Day23
开发语言·python·学习
大白的编程日记.1 小时前
【Linux学习笔记】理解一切皆文件实现原理和文件缓冲区
linux·笔记·学习
小石(努力版)1 小时前
嵌入式STM32学习——外部中断EXTI与NVIC的基础练习⭐
stm32·单片机·学习
小堃学编程2 小时前
前端学习(3)—— CSS实现热搜榜
前端·学习