Laravel 5.2 ServiceProvider 中无法使用 Cache
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Cache;
use App;
use View;
class GlobalProvider extends ServiceProvider
{
public function boot()
{
//
}
public function register()
{
//
$this->app->singleton('g_names', function(){
return Cache::get('names');
});
View::share('g_names', App::make('g_names'));
}
}
FatalThrowableError in Facade.php line 218:
Fatal error: Call to undefined method Illuminate\Support\Facades\Cache::get()
in Facade.php line 218
at Facade::__callStatic('get', array('names')) in GlobalProvider.php line 19
at GlobalProvider->App\Providers{closure}(object(Application), array()) in Container.php line 735
推荐文章: