supportResponse 报错,啥情况

wekyun

问题描述

ArgumentCountError: Too few arguments to function Workerman\Protocols\Http\Request::__construct(),

程序代码

<?php

namespace plugin\wekbbs\app\controller;

use support\Request;
use support\Response;
use Webman\Captcha\CaptchaBuilder;

class ImageController
{
    // /app/wekbbs/ImageController/loginCaptcha
    public function loginCaptcha(): Response
    {
        $request = new Request();
        var_dump($request);
//        // 初始化验证码类
        $builder = new CaptchaBuilder;
        // 生成验证码
        $builder->build();
        // 将验证码的值存储到session中
        $request->session()->set('captcha', strtolower($builder->getPhrase()));
        // 获得验证码图片二进制数据
        $img_content = $builder->get();
        // 输出验证码二进制数据
        return response($img_content, 200, ['Content-Type' => 'image/jpeg']);
    }
}

报错信息

ArgumentCountError: Too few arguments to function Workerman\Protocols\Http\Request::__construct(), 0 passed in E:\gitee\wekbbs\plugin\wekbbs\app\controller\ImageController.php on line 18 and exactly 1 expected in E:\gitee\wekbbs\vendor\workerman\workerman\Protocols\Http\Request.php:80
Stack trace:
#0 E:\gitee\wekbbs\plugin\wekbbs\app\controller\ImageController.php(18): Workerman\Protocols\Http\Request->__construct()
#1 E:\gitee\wekbbs\vendor\workerman\webman-framework\src\App.php(325): plugin\wekbbs\app\controller\ImageController->loginCaptcha(Object(support\Request))
#2 E:\gitee\wekbbs\vendor\workerman\webman-framework\src\App.php(141): Webman\App::Webman\{closure}(Object(support\Request))
#3 E:\gitee\wekbbs\vendor\workerman\workerman\Connection\TcpConnection.php(646): Webman\App->onMessage(Object(Workerman\Connection\TcpConnection), Object(support\Request))
#4 E:\gitee\wekbbs\vendor\workerman\workerman\Events\Select.php(311): Workerman\Connection\TcpConnection->baseRead(Resource id #345)
#5 E:\gitee\wekbbs\vendor\workerman\workerman\Worker.php(1479): Workerman\Events\Select->loop()
#6 E:\gitee\wekbbs\vendor\workerman\workerman\Worker.php(1399): Workerman\Worker::forkWorkersForWindows()
#7 E:\gitee\wekbbs\vendor\workerman\workerman\Worker.php(560): Workerman\Worker::forkWorkers()
#8 E:\gitee\wekbbs\vendor\workerman\webman-framework\src\support\App.php(131): Workerman\Worker::runAll()
#9 E:\gitee\wekbbs\start.php(4): support\App::run()
#10 {main}

截图报错信息里报错文件相关代码

截图

操作系统及workerman/webman等框架组件具体版本

windows下新版webman

736 1 0
1个回答

咸鱼姥爷
public function loginCaptcha(Request $request): Response
  • wekyun 2023-07-05

    他的类不能直接继承用,

年代过于久远,无法发表回答
×
🔝