Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

abkrim's avatar
Level 13

Kernel.php has a limit of written commands?

I have a Kernel.php class

<?php

namespace App\Console;

use App\Console\Commands\Tasks\Api\AnalyzerCallsCommand;
use App\Console\Commands\Tasks\Api\ModemCallsCommand;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule): void
    {
        $params = ['--api=v1', '--all'];

        if (config('sitelight.api.debug')) {
            $params[] = '--debug';
        }

        if (config('sitelight.commands.modems')) {
            $schedule
                ->command(ModemCallsCommand::class, $params)
                //->everyFourHours()
                ->cron(config('sitelight.cron.modems'));
        }
        if (config('sitelight.commands.analyzers')) {
            $schedule
                ->command(AnalyzerCallsCommand::class, $params)
                //->everyFifteenMinutes()
                ->cron(config('sitelight.cron.analyzers'));
        }

        if (config('sitelight.commands.converter')) {
            $schedule->command('elk:analyzer')->everyFifteenMinutes();
            $schedule->command('elk:command')->everySixHours();
        }

        // Cron for check scheduled_tasks
        if (config('sitelight.queues.scheduled.is_active')) {
            $schedule->command('task:cron_scheduled')->everyMinute();
            //$schedule->command('task:check_scheduled')->everyMinute();
        }

        // Cron for update sun events
        $schedule->command('task:updateSunInfo')->cron('1 0,3 * * * ');

        // Cron for prune jobs failed
//        $schedule->command('queue:prune-failed', ['--hours=48'])->cron('12 2 * * *');

//        // Prune expired tokens
         //$schedule->command('sanctum:prune-expired --hours=24')->daily();
//
//        // Prune Bouncer abilities
//        $schedule->command('bouncer:clean')->weekly();
//
//        // Update total-consumption
         //$schedule->command('task:update-total-consumption-command')->cron('*/5 * * * *');
        //$schedule->command('task:update-total-consumption-command')->cron('0,5,10,15,20,25,30,35,40,45,50,55 * * * *');
    }

    protected function commands(): void
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

If uncomment any of last schduled on bottom, when run php artisan a schedule:list get error

a schedule:list

   ErrorException 

  Undefined array key 5

  at vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleListCommand.php:187
    183▕     {
    184▕         $expressions = preg_split("/\s+/", $expression);
    185▕ 
    186▕         return collect($spacing)
  ➜ 187▕             ->map(fn ($length, $index) => str_pad($expressions[$index], $length))
    188▕             ->implode(' ');
    189▕     }
    190▕ 
    191▕     /**

      +2 vendor frames 

  3   [internal]:0
      Illuminate\Console\Scheduling\ScheduleListCommand::Illuminate\Console\Scheduling\{closure}()
      +15 vendor frames 

  19  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

But if comment any of top commands, not fails

Foir example comment //$schedule->command('task:updateSunInfo')->cron('1 0,3 * * * '); and new run

 a schedule:list

  0,5,10,15,20,25,30,35,40,45,50,55 * * * *  php artisan task:update-total-consumption-command ......................................................................... Next Due: en 4 minutos

```
I'm lost...

There are any limits of commands?

In-depth error log... very strange.

a schedule:list

Error

Class "Redis" not found

at vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:81 77▕ * @throws \LogicException 78▕ */ 79▕ protected function createClient(array $config) 80▕ { ➜ 81▕ return tap(new Redis, function ($client) use ($config) { 82▕ if ($client instanceof RedisFacade) { 83▕ throw new LogicException( 84▕ extension_loaded('redis') 85▕ ? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'

0 likes
2 replies
LaryAI's avatar
Level 58

The error message "Undefined array key 5" is related to the schedule:list command and not to the number of commands in the Kernel.php file. The error message "Class 'Redis' not found" is related to the Redis package not being installed or configured properly.

To fix the first error, try running the command "php artisan schedule:run" instead of "php artisan schedule:list". This will execute the scheduled commands and should not produce any errors.

To fix the second error, make sure that the Redis package is installed and configured properly in your Laravel application. You can install the package using Composer by running the command "composer require predis/predis". Then, update your .env file with the Redis credentials and update the config/database.php file to use Redis as the default cache and session driver.

Here is an example of how to configure Redis in Laravel:

// .env file
CACHE_DRIVER=redis
SESSION_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

// config/database.php file
'redis' => [
    'client' => 'predis',
    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => 0,
    ],
],
abkrim's avatar
Level 13

Now get error if activate $schedule->command('task:updateSunInfo')->cron('1 0,3 * * * ');

But if deactivate any of top $scheduled->commands... work fine.

Please or to participate in this conversation.