Laravel 5与Sentry RouteServiceProvider

时间:2015-04-19 13:44:21

标签: php laravel-5 upgrade cartalyst-sentry

尝试升级到Laravel并遵循此Laravel 5 upgrade

但是当谈到Sentry的过滤路线时。我收到这个错误:

FatalErrorException in RouteServiceProvider.php line 38: Class 'App\Providers\Session' not found

与之前的L4过滤器相关的复制和粘贴:

 namespace App\Providers;
 use Cartalyst\Sentry\Facades\Laravel\Sentry;
 use Illuminate\Routing\Router;
 use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
 use Illuminate\Support\Facades\Route;

 class RouteServiceProvider extends ServiceProvider {
   protected $namespace = NULL;   //using composer

   public function boot(Router $router)
   {
     parent::boot($router);

     Route::filter('Sentry', function(){
       if (!Sentry::check()) {
          Session::put('loginRedirect', Request::url());
          return Redirect::guest('login');
        } 
     });
   }
 }

“会话”是个问题。 任何帮助表示感谢,谢谢。

2 个答案:

答案 0 :(得分:0)

您必须导入Session

use Session;

或者以反斜杠

作为前缀
\Session::put('loginRedirect', Request::url());

RequestRedirect

也是如此

答案 1 :(得分:0)

Session facade存在于全局命名空间下。由于您的文件位于App\Providers命名空间下,因此您必须使用\Session::put('loginRedirect', Request::url());而不是Session::put('loginRedirect', Request::url());