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

相关推荐
果粒chenl2 分钟前
React学习(四) --- Redux
javascript·学习·react.js
im_AMBER44 分钟前
CSS 01【基础语法学习】
前端·css·笔记·学习
向阳花开_miemie1 小时前
Android音频学习(二十二)——音频接口
学习·音视频
胡萝卜3.01 小时前
深入理解string底层:手写高效字符串类
开发语言·c++·学习·学习笔记·string类·string模拟实现
fanstering1 小时前
腾讯混元P3-SAM: Native 3D Part Segmentation
笔记·学习·3d·点云
im_AMBER2 小时前
数据结构 05 栈和队列
数据结构·笔记·学习
报错小能手3 小时前
linux学习笔记(31)网络编程——TCP time_wait机制
linux·笔记·学习
Yupureki3 小时前
从零开始的C++学习生活 7:vector的入门使用
c语言·c++·学习·visual studio
i学长的猫3 小时前
Ruby小白学习路线
开发语言·学习·ruby
送秋三十五3 小时前
Docker 构建教程:学习上下文、架构和性能优化技术
学习·docker·架构