Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 609
oldstyle inn Avatar asked Mar 18 '15 20:03

oldstyle inn


1 Answers

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); 
like image 179
NaN Avatar answered Sep 27 '22 18:09

NaN