使用Cron Jobs时未定义的REMOTE_ADDR-Laravel背包 [英] Undefined REMOTE_ADDR when using Cron Jobs - Backpack for Laravel
问题描述
在将Cron Jobs和Backpack用于Laravel时,有人遇到过问题吗?我得到未定义索引:LicenseCheck.php:22上的'REMOTE_ADDR'" (这是一个背包文件).似乎在使用cron作业时,未在LicenseCheck.php中定义$ _SERVER ['REMOTE_ADDR'].有什么想法吗?
Has anyone faced an issue when using Cron Jobs with Backpack for Laravel? I am getting "Undefined index: 'REMOTE_ADDR' at LicenseCheck.php:22" (that's a Backpack file). It seems like when using a cron job, $_SERVER['REMOTE_ADDR'] in LicenseCheck.php is not defined. Any thoughts?
推荐答案
这可能是因为 $ _ SERVER ['REMODE_ADDR']
仅在有远程地址的情况下定义,即有人请求您输入浏览器中的页面.使用cron时,脚本将在本地执行,并且该设置可能为空.如果它破坏了代码,请尝试在脚本开始时自行设置:
That's probably because $_SERVER['REMODE_ADDR']
is only defined when there's, well, a remote address, i.e. somebody requests your page from a browser. With cron the script is executed locally and the setting may be empty.
If it breaks your code, try setting it yourself at the start of the script:
if( !isset($_SERVER['REMODE_ADDR']) ) {
$_SERVER['REMODE_ADDR'] = '127.0.0.1';
}
这篇关于使用Cron Jobs时未定义的REMOTE_ADDR-Laravel背包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!