Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DevFromRotterdam's avatar

The dd stands for "dump and die" so before being able to perform a logout the parser has been allready stopped ('died').

1 like
bbmattieu9's avatar

@36864 thanks so much. it works now. I will flag it as solved. bUT I noticed another funny behaviour with the app...I am trying to use the auth middleware to protect my posts, so in the postController constructor, i passed in this to it:

$this->middleware('auth');

but i noticed when i am not signed it, it generates an error saying Route[login] not defined. but when I am signed in and click link to Posts...it works fine.

rin4ik's avatar

it is redirects you to /login but you login page is/auth/login

bbmattieu9's avatar

@DevFromRotterdam thanks for the info. @rin4ik thanks..it worked but i noticed a funny behaviour in the PostController;When i am not logged it and i try to click on the link to Posts, it generates a Route[login] not defined error. But when i AM logged in, it goes to the expected page. i DID this in the __construct method $this->middleware('auth');

rin4ik's avatar

change method in Illuminate\Foundation\Exceptions\Handler.php;

protected function unauthenticated($request, AuthenticationException $exception)
    {
        return $request->expectsJson()
                    ? response()->json(['message' => $exception->getMessage()], 401)
                    : redirect('/auth/login');
    }
1 like
rin4ik's avatar

@bbmattieu9 you haven't specified route name in your login route. simple way change your route instead of changing handler class it will work as expected. add 'as'=>'login'

Route::get('auth/login',[ 'uses' => 'Auth\LoginController@getLogin', 'as '=>'login' ]);
1 like
36864's avatar

The auth middleware will throw an UnauthenticatedException when the user isn't authenticated, which your exception handler will handle by default by redirecting the user to the login route, which you have not defined.

You can change the redirection route in app\Exceptions\Handler.php

1 like
bbmattieu9's avatar

@rin4ik yea. it works for me. i changed the route name back to 'login' and it works fine now.

@36864 thanks for your time. i really appreciate your help.

you all make my laravel learning more interesting for me. I'll share with you the complete app for you to criticise when i am done.

1 like
bbmattieu9's avatar

@DevFromRotterdam @rin4ik @36864 Is dd() almost the same with using var_dump in OOPHP?? Seem like it will be helpful for debugging. Where can I read more bout it. So as to know when to apply it to check whatever needs to be checked.

Previous

Please or to participate in this conversation.