hyperf / hyperf-docker

🐳 The docker image offered by Hyperf.
https://hub.docker.com/r/hyperf/hyperf
301 stars 203 forks source link

config-nacos组件在解析nacos里面yaml数据报错 #31

Closed iepngs closed 3 years ago

iepngs commented 3 years ago

Execute the command and paste the result below.

Command: uname -a && php -v && composer info | grep hyperf && php --ri swoole

bash-5.0# uname -a && php -v && composer info | grep hyperf && php --ri swoole
Linux 1976dff90a1f 4.15.0-128-generic #131-Ubuntu SMP Wed Dec 9 06:57:35 UTC 2020 x86_64 Linux
PHP 7.4.21 (cli) (built: Jul  4 2021 16:41:27) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
hyperf/cache                         v2.2.0  A cache component for hyperf.
hyperf/command                       v2.2.0  Command for hyperf
hyperf/config                        v2.2.0  An independent component that provides configuration container.
hyperf/config-center                 v2.2.0  The abstraction component of config center
hyperf/config-nacos                  v2.2.0  A nacos adapter for config center component.
hyperf/constants                     v2.2.0  A constants component for hyperf.
hyperf/consul                        v2.2.0  A Consul Client for Hyperf.
hyperf/contract                      v2.2.0  The contracts of Hyperf.
hyperf/database                      v2.2.0  A flexible database library.
hyperf/db-connection                 v2.2.0  A hyperf db connection handler for hyperf/database.
hyperf/devtool                       v2.2.0  A Devtool for Hyperf.
hyperf/di                            v2.2.1  A DI for Hyperf.
hyperf/dispatcher                    v2.2.0  A HTTP Server for Hyperf.
hyperf/engine                        v1.1.6 
hyperf/event                         v2.2.0  an event manager that implements PSR-14.
hyperf/exception-handler             v2.2.0  Exception handler for hyperf
hyperf/framework                     v2.2.0  A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.
hyperf/guzzle                        v2.2.0  Swoole coroutine handler for guzzle
hyperf/http-message                  v2.2.0  microservice framework base on swoole
hyperf/http-server                   v2.2.1  A HTTP Server for Hyperf.
hyperf/ide-helper                    v2.2.0  IDE help files for Hyperf.
hyperf/json-rpc                      v2.2.0  A JSON RPC component for Hyperf RPC Server or Client.
hyperf/load-balancer                 v2.2.0  A load balancer library for Hyperf.
hyperf/logger                        v2.2.0  A logger component for hyperf.
hyperf/memory                        v2.2.0  An independent component that use to operate and manage memory.
hyperf/model-listener                v2.2.0  A model listener for Hyperf.
hyperf/nacos                         v2.2.0  Nacos SDK
hyperf/pool                          v2.2.0  An independent universal connection pool component.
hyperf/process                       v2.2.0  A process component for hyperf.
hyperf/redis                         v2.2.0  A redis component for hyperf.
hyperf/rpc                           v2.2.0  A rpc basic library for Hyperf.
hyperf/rpc-client                    v2.2.0  An abstract rpc server component for Hyperf.
hyperf/rpc-server                    v2.2.0  An abstract rpc server component for Hyperf.
hyperf/server                        v2.2.0  A base server library for Hyperf.
hyperf/service-governance            v2.2.0  A service governance component for Hyperf.
hyperf/service-governance-nacos      v2.2.2  A nacos adapter for service governance.
hyperf/testing                       v2.2.0  Testing for hyperf
hyperf/utils                         v2.2.0  A tools package that could help developer solved the problem quickly.

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.7.0
Built => Jul 24 2021 00:10:22
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
spinlock => enabled
rwlock => enabled
openssl => OpenSSL 1.1.1k  25 Mar 2021
dtls => enabled
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.11
mutex_timedlock => enabled
pthread_barrier => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

Description:

使用的docker镜像:hyperf/hyperf:7.4-alpine-v3.12-swoole config-nacos组件在解析nacos里面yaml数据报错

[ERROR] Error: Call to undefined function Hyperf\ConfigNacos\yaml_parse()(0) in /xx/vendor/hyperf/config-nacos/src/Client.php:85 Stack trace:

0 /xx/vendor/hyperf/config-nacos/src/Client.php(67): Hyperf\ConfigNacos\Client->decode()

1 /xx/vendor/hyperf/config-center/src/AbstractDriver.php(132): Hyperf\ConfigNacos\Client->pull()

2 /xx/vendor/hyperf/config-center/src/AbstractDriver.php(100): Hyperf\ConfigCenter\AbstractDriver->pull()

3 /xx/vendor/hyperf/config-center/src/Listener/FetchConfigOnBootListener.php(34): Hyperf\ConfigCenter\AbstractDriver->fetchConfig()

4 /xx/vendor/hyperf/event/src/EventDispatcher.php(48): Hyperf\ConfigCenter\Listener\FetchConfigOnBootListener->process()

5 /xx/vendor/hyperf/process/src/AbstractProcess.php(127): Hyperf\Event\EventDispatcher->dispatch()

6 {main}

[INFO] Process[config-center-fetcher.0] stopped.

Steps To Reproduce:

var_dump(function_exitsts('yaml_parse'));

打印的结果是:false

config_center.php配置:

'nacos' => [
    'driver' => Hyperf\ConfigNacos\NacosDriver::class,
    'merge_mode' => Hyperf\ConfigNacos\Constants::CONFIG_MERGE_OVERWRITE,
    'interval' => 3,
    'default_key' => 'nacos_config',
    'listener_config' => [
        // dataId, group, tenant, type, content
        'nacos_config' => [
            'tenant'    => 'tenant',
            'data_id'   => 'redis',
            'group'     => 'ii',
            'type'      => 'yml',
        ],
        'nacos_config.data' => [
            'data_id'   => 'hyperf-service-config-yml',
            'group'     => 'DEFAULT_GROUP',
            'type'      => 'yml',
        ],
    ],
],
limingxinleo commented 3 years ago

自己装一个到 docker 里就行了

luxin88 commented 3 years ago

apk add --no-cache php7-dev php7-pear pcre2-dev yaml-dev build-base autoconf pecl install yaml echo "extension=yaml.so" > /etc/php7/conf.d/00_yaml.ini