I\'m going crazy about this error. I\'ve got a vagrant VM with Debian 7, generated with Puphpet, installation was fine.
That error is because you have installed and enabled the module php5-redis, it became with the class Redis. To avoid that error and use the Laravel Redis Facade, you have to change the alias in app/config/app.php (or whatever is your environment).
'Redis' => 'Illuminate\Support\Facades\Redis'
'RedisFacade' => 'Illuminate\Support\Facades\Redis' //whatever you like
or just configure your cache.php to use Redis and use only the Cache class. :)
The problem isn't with your redis server setup -- there's something mis-configured or changed in your system.
The error you're seeing
Call to undefined method Redis::connection()
Is PHP telling you it can't find a method named connection
on the class Redis
. It's a PHP error, and PHP never gets around to trying to talk to the redis server.
Normally, in a Laravel 4.2 system, there is no class named Redis
. Instead, an alias is setup in app/config/app.php
#File: app/config/app.php
'Redis' => 'Illuminate\Support\Facades\Redis',
which turns Redis
into a facade. This is what enables you to make calls like Redis::connection
.
So, there's something wrong with your system. Either you
Have a custom class named Redis
somewhere that's loaded before the aliases are setup
Have Redis
aliased to something other than a the Illuminate\Support\Facades\Redis
facade class
You Redis
facade class has been modified to return a service identifier other than redis
You've rebound the redis
service as some other class
Per the comments below, you have the Redis
PHP extension installed and the global extension class "wins"
To find out where PHP thinks the Redis
class is, try
$r = new ReflectionClass('Redis');
var_dump($r->getClassFile());
To see if #4
is the problem, try calling the service directly
$app = app();
$app['redis']->connection();
Good luck!
Install Redis extension on your PC.
Download the CORRECT version the DDL from the following link: https://pecl.php.net/package/redis/4.1.0/windows
Put the dll in the correct folder
Wamp -> C:\wamp\bin\php\php-XXXX\ext
Laragon -> C:\laragon\bin\php\php-XXX\ext
Edit the php.ini
file adding
extension=php_redis.dll
Restart server and check phpinfo();
. Now Redis should be there!
I came across this after encountering this issue and wanted to add another answer in case it helps someone else.
In my case there was an alias collision because my php configuration has the PHP-Redis module/extension enabled -- both the PHP module and Laravel seem to have a conflicting object named Redis. I was able to resolve this simply by using the entire namespaced identifier:
//$r = Redis::connection()
$r = Illuminate\Support\Facades\Redis::connection();