Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

php - How can I use sentry with 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.

Update: I used the instructions for Laravel 4.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have this working.

  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.

  2. 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",

It should look something like:

"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. (Presuming linux with no aliases) Run php composer.phar dump-autoload then php composer.phar update

  2. 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

  3. 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. 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

    use CartalystSentryFacadesLaravelSentry;

The boot method should look something like:

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');
            }
        });

        //
    }

UPDATE 02-26-15

  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.

Hope it helps.

Wayne Leiser, I.T. Director

B2B I.T. Solutions

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...