lamarus/sentry-driver

此包已 弃用 且不再维护。未建议替代包。

Laravel 4 和 Sentry 2 的认证驱动程序

0.6 2014-02-09 01:16 UTC

This package is not auto-updated.

Last update: 2020-01-20 03:38:46 UTC


README

这是一个为Laravel 4添加sentry驱动程序的提供程序。
endorse

安装

首先,通过Composer安装此包。编辑项目的 composer.json 文件以要求 lamarus/sentry-driver

"require": { "lamarus/sentry-driver": "dev-master" }, "minimum-stability" : "dev"

接下来,在终端中更新Composer

composer update 

添加配置后,添加服务提供程序。打开 app/config/app.php,并在提供程序数组中添加一个新项目。

'Lamarus\SentryDriver\SentryDriverServiceProvider'

最后一步是更改认证驱动程序。打开 app/config/auth.php,并将驱动程序更改为 sentry

使用方法

此驱动程序替代品已被创建,以便于替换当前的认证。所有命令都是相同的,使用方法与当前方式相同。

示例

Route::get('login/once', function() {
   if(Auth::once(['email'=>'test@gmail.com', 'password'=>'test'])) {
    return Redirect::to('check');
  } else {
    return Redirect::to('error');
  }
});

Route::get('login/remember', function() {
 
   if(Auth::attempt(['email'=>'test@gmail.com', 'password'=>'test'], true)) {
    return Redirect::to('check');
  } else {
    return Redirect::to('error');
  }
});

Route::get('login/{id}', function($id) {
  Auth::loginUsingId($id);
});

Route::get('login', function() {
  if(Auth::attempt(['email'=>'test@gmail.com', 'password'=>'test'])) {
    return Redirect::to('check');
  } else {
    return Redirect::to('error');
  }
});

Route::get('logout', function() {
  var_dump(Auth::logout());
});

Route::get('check', function() {

  if(Auth::check()) {
    print Auth::user()->email . '<br/>';
  }

  var_dump(Auth::check());
});

Route::get('error', function() {
  print_r(Session::get('SentryException'));
});