0

i want to php artisan cache:clear and also want to not remove/empty laravel horizon dashboard

my horizon package is "laravel/horizon": "^5.15"

my env variable is like bellow

CACHE_DRIVER=redis

QUEUE_CONNECTION=redis

SESSION_DRIVER=redis

REDIS_CLIENT=predis

REDIS_KEY=oqmm

REDIS_DATABASE=10

REDIS_HOST=127.0.0.1

REDIS_PASSWORD=null

REDIS_PORT=6379

also my local configuration is like bellow

`'local' => [
     'supervisor-1' => [
         'connection' => 'redis',
         'queue' => ['default'],
         'balance' => 'auto',
         'processes' => 3,
         'tries' => 3,
     ],
],`

i change this env variable for database driver but it's not working and not showing any data in horizon dashboad

QUEUE_CONNECTION=database

is that any solution or any other way to view GUI for job queue ?

objg
  • 11
  • 2

1 Answers1

0

You can use a separate cache driver for the Horizon dashboard data. You can do this by adding the following configuration to your config/horizon.php file:

    <?php

return [
    // ...
    
    'environments' => [
        'local' => [
            'supervisor-1' => [
                'connection' => 'redis',
                'queue' => ['default'],
                'balance' => 'auto',
                'processes' => 3,
                'tries' => 3,
            ],
        ],
    ],
    
    'redis' => [
        'client' => 'predis',
        'options' => [
            'cluster' => 'redis',
            'prefix' => env('REDIS_PREFIX', 'horizon:'),
        ],
        'default' => [
            'url' => env('REDIS_URL'),
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', '6379'),
            'database' => env('REDIS_DB_HORIZON', '10'),
        ],
    ],
    
    // ...
];

Then add a new connection configuration for your database driver in config/database.php .This is an example configuration for a MySQL database

<?php

return [
    // ...

    'connections' => [
        // ...

        'horizon' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'horizon'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],

        // ...
    ],

    // ...
];

Then clear your cache

php artisan cache:clear && php artisan horizon:terminate
Balaji Kandasamy
  • 4,446
  • 10
  • 40
  • 58
  • i add after environments configuration but this is not working, can you please give full configuration for this solution in config/horizon.php – objg Apr 05 '23 at 12:59