首页
下载
文档
社区
视频
捐赠
源代码
赞助商
AOT 编译器
AI 助理
商业产品
PHP AOT 原生编译器
Swoole-Compiler 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
PHP-FPM模式下,可以使用swoole的协程吗?报错Call to undefined function Swoole\Coroutine\run()
### 问题描述 PHP-FPM模式下,报错Call to undefined function Swoole\Coroutine\run() ### Swoole版本 4.7.0,PHP版本7.2,Ubuntu20 ### 相关代码 ```php use Swoole\Runtime; use Swoole\Coroutine; use function Swoole\Coroutine\run; error_reporting(E_ALL); ini_set('display_errors', 'on'); $s = microtime(true); // Swoole\Coroutine\run()见'协程容器'章节 run(function () { for ($c = 500; $c--;) { Coroutine::create(function () { $pdo = new PDO('mysql:host=127.0.0.1;dbname=test;charset=utf8', 'test', 'test'); $statement = $pdo->prepare('SELECT MAX(id) FROM `users`'); for ($n = 1; $n--;) { $statement->execute(); var_dump($statement->fetchAll()); } }); } }); echo 'use '.(microtime(true) - $s).' s'; ``` ### cli模式可以输出,但是php-fpm则报错
发布于5年前 · 90 次浏览 · 来自
提问
CoinB
### 问题描述 PHP-FPM模式下,报错Call to undefined function Swoole\Coroutine\run() ### Swoole版本 4.7.0,PHP版本7.2,Ubuntu20 ### 相关代码 ```php use Swoole\Runtime; use Swoole\Coroutine; use function Swoole\Coroutine\run; error_reporting(E_ALL); ini_set('display_errors', 'on'); $s = microtime(true); // Swoole\Coroutine\run()见'协程容器'章节 run(function () { for ($c = 500; $c--;) { Coroutine::create(function () { $pdo = new PDO('mysql:host=127.0.0.1;dbname=test;charset=utf8', 'test', 'test'); $statement = $pdo->prepare('SELECT MAX(id) FROM `users`'); for ($n = 1; $n--;) { $statement->execute(); var_dump($statement->fetchAll()); } }); } }); echo 'use '.(microtime(true) - $s).' s'; ``` ### cli模式可以输出,但是php-fpm则报错
赞
0
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
登录
后参与评论
评论
2021-07-17
鲁飞
不支持。仅支持CLI模式。
赞
1
回复