0

I am fighting with phpredis + laravel 5.5. (PHP 7.2, nginx, ubuntu) The following code works well. That means the server is configured properly. Also the redis-cli works ok.

$redis = new Redis();
$con = $redis->connect('127.0.0.1', 6379);
$redis->auth('password');   

$redis->ping();

This one:

$redis = Redis::connection();

throws: Call to undefined method Redis::connection()

And this line:

Redis::set('name', 'Taylor')

throws: Redis server went away

I tried renaming the alias in config/app as some advice suggested, but it didn't help. Any idea, please?

Edit: composer.json

"require": {
    "php": ">=7.0.0",
    "laravel/framework": "5.5.7",
    "laravelcollective/html": "^5.3",
    "laravel/tinker": "~1.0",
    "intervention/image": "~2.0",
    "laravel/passport": "^4.0.2",
    "laracasts/utilities": "~2.0",
    "srmklive/paypal": "1.5.5",
    "guzzlehttp/guzzle": "~6.0",
    "torann/geoip": "^1.0",
    "doctrine/dbal": "^2.6",
    "mews/purifier": "~2.0",
    "talvbansal/media-manager": "2.5",
    "roumen/sitemap": "^2.7",
    "predis/predis": "^1.1"

},

config/database.php:

'redis' => [

    'client' => 'phpredis',

'cluster' => false,

    'default' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', 6379),
        'database' => 0,

    ],

],
Peter Matisko
  • 2,113
  • 1
  • 24
  • 47

0 Answers0