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

相关推荐
talen_hx29619 分钟前
《零基础入门Spark》学习笔记 Day 17
大数据·笔记·学习·spark
北山有鸟23 分钟前
Linux第一宏:container_of
笔记·嵌入式硬件·学习
炽烈小老头37 分钟前
【 每天学习一点算法 2026/04/21】螺旋矩阵
学习·算法
charlie1145141911 小时前
嵌入式Linux驱动开发(3)——内核模块机制 - Linux 的插件系统
linux·运维·开发语言·驱动开发·嵌入式硬件·学习
喜欢吃燃面2 小时前
Linux 进程信号深度解析:从概念到产生机制
linux·开发语言·学习
小神.Chen2 小时前
Rainmeter 中如何修改自己喜欢的字体
学习·软件构建
VelinX3 小时前
【个人学习||agent底层】01创建基础的发送和模型建立联系
学习
知识分享小能手3 小时前
ECharts入门学习教程,从入门到精通,ECharts高级功能(6)
前端·学习·echarts
GISer_Jing3 小时前
Jinger独自勇闯Microsoft AI TourShanghai
学习·新浪微博