webman2.1 使用了swoole作为驱动
在测试协程上下文传输时报错
composer
"php": ">=8.1",
"workerman/webman-framework": "^2.1",
"monolog/monolog": "^2.0",
"webman/console": "^2.1",
"webman/rate-limiter": "^1.1",
"workerman/validation": "^3.1",
"webman/redis": "^2.1",
"illuminate/events": "^11.43",
"vlucas/phpdotenv": "^5.6",
"webman/cache": "^2.1",
"workerman/coroutine": "^1.1.3",
"webman/database": "^2.1",
"illuminate/pagination": "*",
"symfony/var-dumper": "^7.2",
"webman/log": "^2.1"
发下 config/process.php
贴全,包括命名空间
use support\Log;
use support\Request;
use app\process\Http;
global $argv;
return [
'webman' => [
'handler' => Http::class,
'listen' => 'http://0.0.0.0:8787',
'count' => 2,
'user' => '',
'group' => '',
'reusePort' => false,
'eventLoop' => '',
'context' => [],
'constructor' => [
'requestClass' => Request::class,
'logger' => Log::channel('default'),
'appPath' => app_path(),
'publicPath' => public_path()
]
],
'swoole' =>[
'handler' => Http::class,
'listen' => 'http://0.0.0.0:8888',
'count' => 2,
'user' => '',
'group' => '',
'reusePort' => false,
'eventLoop' => Workerman\Events\Swoole::class,
'context' => [],
'constructor' => [
'requestClass' => Request::class,
'logger' => Log::channel('default'),
'appPath' => app_path(),
'publicPath' => public_path()
]
],
// File update detection and automatic reload
'monitor' => [
'handler' => app\process\Monitor::class,
'reloadable' => false,
'constructor' => [
// Monitor these directories
'monitorDir' => array_merge([
app_path(),
config_path(),
base_path() . '/process',
base_path() . '/support',
base_path() . '/resource',
base_path() . '/.env',
], glob(base_path() . '/plugin//app'), glob(base_path() . '/plugin//config'), glob(base_path() . '/plugin/*/api')),
// Files with these suffixes will be monitored
'monitorExtensions' => [
'php', 'html', 'htm', 'env'
],
'options' => [
'enable_file_monitor' => !in_array('-d', $argv) && DIRECTORY_SEPARATOR === '/',
'enable_memory_monitor' => DIRECTORY_SEPARATOR === '/',
]
]
]
];
从报错看是使用了错误的Request类,正常应该使用
support/Request
。调用栈里看到使用的是
Workerman\Protocols\Http\Request
类是在 config/process.php 里的 requestClass 指定的,可能你改了什么东西,用了错误的Request类。
检查了一下,我控制器业务代码里引用的就是 use support\Request;这个问题我重启容器后又好了QWQ
类是在 config/process.php 里的 requestClass 指定的,可能之前配置是错的
老大 应该不是这个问题 这个情况又复现了 经常出现这种情况
项目是新起的 基本只写了几个测试的接口
写一个能稳定复现的例子,打包发到我邮箱 walkor@workerman.net
写明重现步骤。主要,要能重现问题的例子。