oldstyle inn
oldstyle inn

Reputation: 125

Laravel 5 Class 'App\Http\Controllers\Cache' not found

When I use cache on laravel, 5 it keeps on giving me an error Class 'App\Http\Controllers\Cache' not found

<?php namespace App\Http\Controllers;

class ChannelController extends Controller {

    public function popular()
    {
        Cache::put('test','test value',10);
    }
}

It's just a simple cache but still not working. By the way, my config for cache is set to memcached - and it is working fine on laravel 4.2, but not on laravel 5.

Upvotes: 11

Views: 14044

Answers (2)

NaN
NaN

Reputation: 717

Cache is not inside your App namespace, you can either:

<?php namespace App\Http\Controllers;

use \Cache;
class ChannelController extends Controller {

You can then use Cache throughout your class. Alternatively you can add a \ to the existing line you have:

\Cache::put('test','test value',10); 

Upvotes: 15

Kelly Kiernan
Kelly Kiernan

Reputation: 365

You just need to import Cache. Add this to the top of your file after the namespace declaration but before your class.

use Cache;

Upvotes: 7

Related Questions