当前位置: 首页 > article >正文

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

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

一、新建命令文件

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这个方法,具体看个人需求

<?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
在这里插入图片描述


http://www.kler.cn/a/584720.html

相关文章:

  • DeepSeek结合Mermaid绘图(流程图、时序图、类图、状态图、甘特图、饼图)转载
  • Linux---sqlite3数据库
  • unity Rigidbody2D、Collider2D参数详解
  • 【Android】adb shell基本使用教程
  • 实现悬浮按钮拖动,兼容h5和微信小程序
  • 鸿蒙Next开发与实战经验总结
  • 浅显易懂——连接池、分布式系统、微服务等概念
  • C语言之数据结构:理解什么是数据结构和算法(启航)
  • 【每日学点HarmonyOS Next知识】嵌套组件、装饰器报错、迭代列表刷新、单位换算、tabs组件生命周期
  • 思维链医疗编程方法论框架(Discuss V1版)
  • Android集成:表格、文档文字快速录入-表格识别接口
  • 【C++】initializer_list在实际开发中的应用
  • 101.在 Vue 3 + OpenLayers 使用 declutter 避免文字标签重叠
  • 【C】初阶数据结构9 -- 直接插入排序
  • 集合进阶——数据结构
  • 洛谷P10576 [蓝桥杯 2024 国 A] 儿童节快乐
  • React篇之three渲染
  • WebRTC技术在音视频处理上的难点剖析:EasyRTC嵌入式视频通话SDK的优化策略
  • Appium等待机制--强制等待、隐式等待、显式等待
  • 一次 诡异 的 JVM OOM 事故 原创