gpt4 book ai didi

laravel - 在 Laravel Scheduler 作业中为 foreach() 提供的参数无效

转载 作者:行者123 更新时间:2023-12-02 10:14:01 24 4
gpt4 key购买 nike

我正在 Laravel 5.8 中使用 Schedular。设置 CommandsCommand Kernal 后,我收到的错误为,

Invalid argument supplied for foreach() at /home/SERVER_USER_NAME/public_html/vendor/symfony/console/Input/ArgvInput.php:261)

这是Kernal 方法,

protected $commands = [
Commands\OfferMonitor::class,
Commands\RankingCommand::class,
Commands\CreditCycle::class,
];

protected function schedule(Schedule $schedule)
{
$schedule->command('KG:OfferMonitor')->dailyAt('01:00');
$schedule->command('KG:UpdateRanks')->everyTenMinutes();
$schedule->command('KG:CreditCycle')->dailyAt('00:00');
}

这是我在生产服务器上运行的 Laravel Cron JobCron Job

我认为 cron 作业本身会引发错误,我使用的是 php 二进制文件而不是 php-cli。是否导致错误?如果是,这个问题的解决方法是什么?

这是来自 Laravel 的完整错误日志和堆栈跟踪,

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

Note: The Commands scheduled in Kernal.php is running properly when I use them with artisan from terminal, so there is no issue about command.

最佳答案

尝试将 cron 命令设置为这样

/usr/local/bin/php register_argc_argv=1 artisan schedule:run >> /dev/null 2>&1

关于laravel - 在 Laravel Scheduler 作业中为 foreach() 提供的参数无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57848968/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com