如何修复在docker.io/openswoole/swoole:php7.4-alpine中找不到的swoole_version,即使加载了openswoole.so

qco9c6ql  于 2023-03-16  发布在  PHP
关注(0)|答案(1)|浏览(112)

我试着用docker图像docker.io/openswoole/swoole:php7.4-alpine给openswoole http服务器发短信,但是,我甚至找不到函数swoole_version(),我已经检查了php --ri openswoole,库在那里,这是输出

openswoole

openswoole

Open Swoole => enabled
Author => Open Swoole Group <hello@openswoole.com>
Version => 22.0.0
Built => Mar 13 2023 02:04:41
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1t  7 Feb 2023
dtls => enabled
http2 => enabled
hook-curl => enabled
pcre => enabled
zlib => 1.2.12
brotli => E16777225/D16777225
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
postgresql => enabled

Directive => Local Value => Master Value
openswoole.enable_coroutine => On => On
openswoole.enable_preemptive_scheduler => Off => Off
openswoole.display_errors => On => On
openswoole.unixsock_buffer_size => 8388608 => 8388608

我试着搜索google/search engine,和git repo,似乎他们只指向未加载的lib或.so文件,但在我的情况下,它在那里。第二次尝试是检查注册的函数,似乎只有一些openswoole函数在那里。
我试着用这个代码检查

<?php 

$function = get_defined_functions()["internal"];

$result = array_filter($function, function($d) { return strpos($d, "swoole") !== false; });

var_dump($result);

输出为

array(23) {
  [1227]=>
  string(23) "swoole_coroutine_create"
  [1228]=>
  string(22) "swoole_coroutine_defer"
  [1229]=>
  string(27) "swoole_coroutine_socketpair"
  [1230]=>
  string(28) "swoole_test_kernel_coroutine"
  [1231]=>
  string(40) "swoole_internal_call_user_shutdown_begin"
  [1234]=>
  string(16) "swoole_event_add"
  [1235]=>
  string(16) "swoole_event_del"
  [1236]=>
  string(16) "swoole_event_set"
  [1237]=>
  string(18) "swoole_event_isset"
  [1238]=>
  string(21) "swoole_event_dispatch"
  [1239]=>
  string(18) "swoole_event_defer"
  [1240]=>
  string(18) "swoole_event_cycle"
  [1241]=>
  string(18) "swoole_event_write"
  [1242]=>
  string(17) "swoole_event_wait"
  [1243]=>
  string(17) "swoole_event_exit"
  [1244]=>
  string(18) "swoole_timer_after"
  [1245]=>
  string(17) "swoole_timer_tick"
  [1246]=>
  string(19) "swoole_timer_exists"
  [1247]=>
  string(17) "swoole_timer_info"
  [1248]=>
  string(18) "swoole_timer_stats"
  [1249]=>
  string(17) "swoole_timer_list"
  [1250]=>
  string(18) "swoole_timer_clear"
  [1251]=>
  string(22) "swoole_timer_clear_all"
}

基于 PHP.netdocs (https://www.php.net/manual/en/ref.swoole-funcs.php),应该有一个名为swoole_version的函数,但似乎是官方的docker映像,而openswoole.so没有它。
它是设计出来的吗?或者我需要支付一些费用才能使用它?或者有一些conf需要我启用?
任何指示都非常感谢。谢谢

tvz2xvvm

tvz2xvvm1#

swoole和openswoole是不一样的。php文档指的是swoole插件,而openswoole是一个具有不同文档的分支:https://openswoole.com/docs
可以在openswoole中使用以下常量:https://github.com/openswoole/ide-helper/blob/master/src/OpenSwoole/Constant.php#L11

\OpenSwoole\Constant::VERSION

也可以使用此函数:
https://github.com/openswoole/ide-helper/blob/4fdabcbb5db48bc8bdc5262208f9d2fc976f4b79/src/OpenSwoole/Util.php#LL13C11-L13C11

\OpenSwoole\Util::getVersion()

相关问题