如何全局取消命令触发事件分发 #4946
huangdijia
started this conversation in
Show and tell
如何全局取消命令触发事件分发
#4946
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
有留意的小伙伴,不难发现 Hyperf 的命令默认会有一个
option
2.x 文档上有说明
3.x 之后默认开启,但可通过
--disable-event-dispatcher
来禁用,没错,跟 2.x 刚好相反。默认开启肯定是有它的道理,这里不讨论。但是,不得不说因为这个调整,踩了一些坑,于是我就想怎么可以取消(不想每次都敲
--disable-event-dispatcher
)。@limingxinleo 很快就给出了方案(增加一个
Hyperf\Command\NullDisableEventDispatcher
),在需要的Command
里面use
一下就可以了,例如:但是问题又来了,Hyperf 自带的命令呢?查看路由、生成模型等等,我改不了源码怎么办?
最后想到了
class_map
,改写Hyperf\Command\DisableEventDispatcher
就好了。然后配字 class_map
看效果:
Beta Was this translation helpful? Give feedback.
All reactions