10

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.

andrewsi
  • 10,807
  • 132
  • 35
  • 51
Ogie
  • 1,304
  • 2
  • 14
  • 17
  • 1
    What have you tried so far? Including this information will help us understand where you went wrong if you went wrong. – Matt Burrow Feb 16 '15 at 10:03
  • 1
    See my instructions below. As far as the information included I am not surprised. Sado probably has ran into the same thing I have. If I include all of the information on a question on stack overflow and spend an hour making sure everything looks picture perfect then I get marked down because I had too much information. If I don't include enough then I get marked down because I didn't have enough. I don't blame him for asking a straight forward question. He wasn't asking for help with an error. He was asking if anyone has done it and how to do it. All the mark down does is piss you off! – scrfix Feb 24 '15 at 04:04
  • Thanks scrfix. Almost felt stupid for asking this question. Even tried to edit the question but didnt know what to really add. – Ogie Feb 25 '15 at 16:55
  • 1
    @SadoOgie You're Welcome. I have been the brunt of people that in my opinion feel they have great power on this site and no matter what you do your question still gets marked down no matter how much time or research you spend and someone marks you down and it just goes to piss you off and tell other people to stay away from the damned website. Now, with that said, not everyone does that. There are helpful people on here obviously because the website is bigger than huge. – scrfix Feb 26 '15 at 10:51
  • Yes some users don't know the difference between questions that are unclear or questions that they simply might not be the best person to answer and should leave for others. – sturrockad Apr 23 '15 at 12:40

4 Answers4

16

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 Cartalyst\Sentry\Facades\Laravel\Sentry;

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.

Dan Davies Brackett
  • 9,811
  • 2
  • 32
  • 54
scrfix
  • 1,188
  • 3
  • 11
  • 24
  • After installing, you can publish the package configuration file into your application by running the following command: `php artisan vendor:publish --provider="Cartalyst\Sentry\SentryServiceProvider"` – Hany Alsamman Oct 24 '15 at 23:47
1

I haven't personally installed it, but I know it's compatible. https://medium.com/@Cartalyst/laravel-5-support-4c11e01c3337

The installation instructions do not have specific Laravel5 information though it should be identical to L4 pending you pull in the correct branch. Assuming you are using composer you can do this by requiring "cartalyst/sentry": "dev-feature/laravel-5" in your composer.json.

Follow the rest of the L4 installation (add to providers and aliases array) and information except remember app.php is no longer in app/config/app.php but in config/app.php

If things are still not working for you, be sure to update your question with at least some information...

Jeremy Schaffer
  • 428
  • 4
  • 9
  • I'm having the same issue, when i updated from L4 to L5 I received this error: Class 'App\Http\Controllers\Sentry' not found Now that I've included these lines in my app.php: 'Cartalyst\Sentry\SentryServiceProvider', // in the providers 'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry', // in the aliases I get this error: BadMethodCallException in ServiceProvider.php line 226: Call to undefined method [package] I'm really stuck on this, could you help me? – Dries Feb 22 '15 at 14:30
  • @Dries - Follow the instructions below. It sounds like you didn't add the add the proper items to your composer.json file. – scrfix Feb 24 '15 at 04:09
0

Try Sentinel: https://github.com/rydurham/Sentinel

add to composer

composer require rydurham/sentinel

In config/app.php

'providers' => array(
    ...
    'Sentinel\SentinelServiceProvider', 
    ...
)

In app/Http/Kernel.php

protected $routeMiddleware = [
    // ..
    'sentry.auth' => 'Sentinel\Middleware\SentryAuth',
    'sentry.admin' => 'Sentinel\Middleware\SentryAdminAccess',
];

then

publish config:

php artisan sentinel:publish

run migrations:

php artisan migrate

run seeder:

php artisan db:seed --class=SentinelDatabaseSeeder

add home route in app/routes.php

 Route::get('/', array('as' => 'home', function()
{
    return View::make('home');
}));

all done, go to myapp.dev/login

DPP
  • 12,716
  • 3
  • 49
  • 46
  • That's all from the documents. However, I'm a newbie and I want to customize Sentinel and add some features. Do you have any clue on that – DucCuong Apr 16 '15 at 04:38
  • for example: email activation after registration and also the role management – DucCuong Apr 16 '15 at 13:45
  • 2
    Please note that `rydurham/Sentinel` supports an older (and deprecated) version of `cartalyst/sentry`. Just to confuse matters, it has no connection whatsoever with `cartalyst/sentinel` (2.0 is now free open source), which is taking over from `cartalyst/sentry`. The documentation is far from clear on this. The tables created by all these libraries also clash, so you can only use one of them. Hopefully being aware of this will help avoid some pain. – Jason Aug 05 '15 at 13:50
0

bootstarpCms use both laravel5 and sentry ,so you can read the source code to learn .here https://github.com/BootstrapCMS/CMS

jamlee
  • 1,234
  • 1
  • 13
  • 26