hyperf / hyperf

🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.
https://www.hyperf.io
MIT License
6.26k stars 1.22k forks source link

[BUG] php bin/hyperf.php server:watch 报错 #2087

Closed zsboss closed 4 years ago

zsboss commented 4 years ago

Execute the command and paste the result below.

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

# Paste the result here.
PHP 7.2.14 (cli) (built: Feb  1 2019 12:25:00) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Sdebug v2.7.3-dev, Copyright (c) 2002-2019, by Derick Rethans
hyperf/async-queue                   v2.0.0             A async queue com...
hyperf/cache                         v2.0.0             A cache component...
hyperf/command                       v2.0.0             Command for hyperf
hyperf/config                        v2.0.0             An independent co...
hyperf/constants                     v2.0.0             A constants compo...
hyperf/contract                      v2.0.1             The contracts of ...
hyperf/database                      v2.0.1             A flexible databa...
hyperf/db-connection                 v2.0.0             A hyperf db conne...
hyperf/devtool                       v2.0.1             A Devtool for Hyp...
hyperf/di                            v2.0.1             A DI for Hyperf.
hyperf/dispatcher                    v2.0.0             A HTTP Server for...
hyperf/event                         v2.0.0             an event manager ...
hyperf/exception-handler             v2.0.0             Exception handler...
hyperf/framework                     v2.0.0             A coroutine frame...
hyperf/guzzle                        v2.0.0             Swoole coroutine ...
hyperf/http-message                  v2.0.1             microservice fram...
hyperf/http-server                   v2.0.1             A HTTP Server for...
hyperf/logger                        v2.0.0             A logger componen...
hyperf/memory                        v2.0.0             An independent co...
hyperf/model-cache                   v2.0.0             A model cache com...
hyperf/model-listener                v2.0.0             A model listener ...
hyperf/paginator                     v2.0.0             A paginator compo...
hyperf/pool                          v2.0.0             An independent un...
hyperf/process                       v2.0.0             A process compone...
hyperf/redis                         v2.0.0             A redis component...
hyperf/server                        v2.0.1             A base server lib...
hyperf/testing                       v2.0.0             Testing for hyperf
hyperf/translation                   v2.0.0             An independent tr...
hyperf/utils                         v2.0.0             A tools package t...
hyperf/validation                    v2.0.0             hyperf validation
hyperf/watcher                       v2.0.1            

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.5.1
Built => May 12 2020 18:53:24
coroutine => enabled
kqueue => enabled
rwlock => enabled
openssl => OpenSSL 1.0.2q  20 Nov 2018
http2 => enabled
pcre => enabled
zlib => 1.2.8
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 => 262144 => 262144

Description:

php bin/hyperf.php server:watch 执行后, 请求方法报 Call to a member function doLogin() on null 但是执行php bin/hyperf.php start 是正常的

huangzhhui commented 4 years ago

/assign @limingxinleo

limingxinleo commented 4 years ago

composer dump-autoload -o,然后再试试

zsboss commented 4 years ago

执行composer dump-autoload -o 可以了,为啥会出现这个问题呢。今天已经好几次出现这个问题了

limingxinleo commented 4 years ago

server:watch 的运行原理是动态修改,跳过扫描。。

所以新增和删除文件,都需要 composer dump-autoload -o

zsboss commented 4 years ago

好的,明白了,谢谢大佬百忙之中解答问题

huangzhhui commented 4 years ago

@limingxinleo 要不要 watcher 里面一起去 dump-autoload -o 呢?

limingxinleo commented 4 years ago

@limingxinleo 要不要 watcher 里面一起去 dump-autoload -o 呢?

那启动速度就会很慢了,除非不执行脚本 -o。嗯,有道理