服务器上的调度程序错误,但在Laravel中不是本地主机上的调度程序错误

问题描述 投票:0回答:1

我正在测试调度程序,为此,我在本地计算机上测试了代码,它可以正常工作,但是在实时服务中,我面临foreach loop的以下错误>


[2019-11-27 23:00:01] local.ERROR: Invalid argument supplied for foreach() {"exception":"[object] (ErrorException(code: 0): Invalid argument supplied for foreach() at /demon/x/public_html/vendor/symfony/console/Input/ArgvInput.php:261)
[stacktrace]
#0 /demon/x/public_html/vendor/symfony/console/Input/ArgvInput.php(261): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Invalid argumen...', '/demon/x...', 261, Array)
#1 /demon/x/public_html/vendor/symfony/console/Application.php(983): Symfony\\Component\\Console\\Input\\ArgvInput->getFirstArgument()
#2 /demon/x/public_html/vendor/laravel/framework/src/Illuminate/Console/Application.php(81): Symfony\\Component\\Console\\Application->getCommandName(Object(Symfony\\Component\\Console\\Input\\ArgvInput))
#3 /demon/x/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#4 /demon/x/public_html/artisan(36): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#5 {main}
"} 


我试图调用的函数如下,该函数在辅助函数中:


   function sendNotificationToScheduleMessages() {
        // from current time 
        $from  = date('Y-m-d H:i:s', strtotime('now'));
        // to the time max
        $to = date('Y-m-d H:i:s', strtotime('+1 minutes', strtotime('now')));

        //get all pending notification between from and to date timestamp
        $notification = ScheduleMessage::whereBetween('trigger_at', [$from, $to])->whereStatusId(4)->get();
        if(count($notification) > 0){
            Log::info('Data fetched for notification #record - '.$notification->id);
        } else {
            Log::info('No Notification found form ('.$from.') - to ('.$to.')');
        }

    }

[我正在测试调度程序,为此,我在本地计算机上测试了代码,它工作正常,但是在实时服务中,我面临以下foreach循环错误[2019-11-27 23:00:01] local.ERROR :无效...

laravel foreach runtime-error shared-hosting
1个回答
0
投票

过去我也遇到过类似的问题。您尚未显示某些调度程序信息,但是我可以通过修复cron指令来解决此问题。因此,在实时服务器上,请确保您确实已将Laravel的调度程序添加到cron

© www.soinside.com 2019 - 2024. All rights reserved.