如何检查当前应用程序进程是否在Laravel的队列环境中运行 [英] How to check If the current app process is running within a queue environment in Laravel
本文介绍了如何检查当前应用程序进程是否在Laravel的队列环境中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过特征将全局范围应用于模型,但是我不希望在从Redis队列中调用/处理模型时应用全局范围.
I applied a global scope to my models via a trait, but I don't want the global scope applied when the model is called/processed from my Redis queue.
如何检测当前实例是否为队列进程?就像我们有这个
How do I detect if the current instance is a queue process? just like we have this
if (App::environment('local')) {
// The environment is local
}
检测应用程序是在本地运行还是在生产环境中运行.
to detect if the app is running in local or production.
推荐答案
简单调用:
app()->runningInConsole();
检查是否通过cli执行.
to check if execution is happening via cli.
这篇关于如何检查当前应用程序进程是否在Laravel的队列环境中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文