如何在laravel 5中使用哨兵? [英] How can I use sentry with laravel 5?

查看:305
本文介绍了如何在laravel 5中使用哨兵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试在laravel 5中安装哨兵,但无法正常工作.我想知道是否有人做过,以及如何做.

I have tried installing sentry in laravel 5 but it doesn't work. I would like to know if anyone has done it and how to do it.

更新:我使用了Laravel 4的说明.

Update: I used the instructions for Laravel 4.

推荐答案

我正在工作.

  1. L5中的Sentry目前没有官方支持.他们在其网站上声明了这项权利.他们正在努力.

  1. There is no official support right now for Sentry in L5. They state this right on their website. They are working on it however.

在require部分中将以下内容添加到您的composer.json文件中.

Add the following to your composer.json file in the require section.

"cartalyst/sentry": "dev-feature/laravel-5",
"illuminate/html": "~5.0"

将以下内容添加到自动加载"部分.

Add the following to the autoload section.

"app/Http/Controllers",

它看起来应该像这样:

"require": {
    "laravel/framework": "5.0.*",
    "cartalyst/sentry": "dev-feature/laravel-5",
    "illuminate/html": "~5.0"
},
"require-dev": {
    "phpunit/phpunit": "~4.0",
    "phpspec/phpspec": "~2.1"
},
"autoload": {
    "classmap": [
        "database",
        "app/Classes",
        "app/Http/Controllers",
        "app/Models"

  1. (假定没有别名的linux)运行 php composer.phar dump-autoload ,然后运行 php composer.phar update

按照下一页上的说明将文件从4.2转换为5.0:

Follow the instructions on the following page to convert your files from 4.2 to 5.0: http://laravel.com/docs/master/upgrade#upgrade-5.0

如果您正在使用HTML Facade for FORMS,则将表单的{{{}}}或{{}}更改为{!! !!},因为L5转义了{{{}}}和{{}}的所有输出.如果要原始输出,则必须使用{!! !!}.

If you are using HTML Facade for FORMS then change {{{ }}} or {{ }} for the FORM's to {!! !!} because L5 escapes all output from {{{ }}} and {{ }}. If you want raw output you must use {!! !!}.

按照#4中的说明将重定向检查移至引导方法后,将以下内容添加到RouteServiceProvider.php的顶部

When you move your redirect check to the boot method as per the instructions in #4 then add the following to the top of the RouteServiceProvider.php

使用Cartalyst \ Sentry \ Facades \ Laravel \ Sentry;

启动方法应类似于:

public function boot(Router $router)
    {
        parent::boot($router);
        // Check if someone is already logged in
        Route::filter('members_auth',function(){
        //If already logged in go to dashboard or else login
            if(!Sentry::check()){
                return Redirect::to('/login');
            }
        });

        //
    }

更新02-26-15

  1. 请勿运行命令 php artisanoptimize ,因为它会破坏哨兵.运行此命令后,我无法弄清楚出了什么问题,但我认为它可能必须与configure.php文件有关,因此我运行了 php artisan Optimize --force 并解决了所有问题.
  1. Do not run the command php artisan optimize as it will break sentry. I could not figure out what was wrong after I ran this but thought it probably has to be with the compiled.php file so I ran php artisan optimize --force and that fixed whatever the issue was.

希望有帮助.

韦恩·莱瑟(Wayne Leiser)导演

Wayne Leiser, I.T. Director

B2B I.T.解决方案

B2B I.T. Solutions

**更新29-03-2018 ** Sentry现在支持Laravel 5.x

** Update 29-03-2018 ** Sentry now supports Laravel 5.x

这篇关于如何在laravel 5中使用哨兵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆