fuel / core

Fuel PHP Framework - The core of the Fuel v1 framework
http://fuelphp.com
813 stars 345 forks source link

Call to undefined method \Redis::instance() #1220

Closed andreoav closed 11 years ago

andreoav commented 11 years ago

I'm trying to use redis as a cache engine in my new APP, I've just installed the redis server and php extension.

Now I'm getting the following error

ErrorException [ Error ]: Call to undefined method Redis::instance() COREPATH/classes/cache/storage/redis.php @ line 58

try
{
    $this->redis = \Redis::instance($this->config['database']);
}
catch (\Exception $e)
{
    throw new \FuelException('Can not connect to the Redis engine. The error message says "'.$e->getMessage().'".');
}

If I go to this file and remove the "\" from "\Redis::instance()" it works fine... I don't know the '\' causes this error.

WanWizard commented 11 years ago

Check if you don't have another class defined called Redis. Some PHP installations seem to have an optional component like that loaded by default, which conflicts with our Redis class.

You can check that simply by creating a test.php, add $x = new Redis(); to it, and load it. If you don't get an error but a Redis object, this is the cause.

If you remove the backslash, the class is loaded from the current namespace (\Fuel\Core), which works because that does not conflict. It will however cause extension issues, and problems when you want to use Redis directly from your app controllers, so this is not a solution.

andreoav commented 11 years ago

I thought was necessary an PHP Redis extension to get Redis working with FuelPHP. I disabled it and everything works fine now.

Thanks.