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

Kemito's avatar

Route hits twice

Hi guys. I am totally stuck with this. I dont understand and cant see why route is hits twice. I try to connect passport to user object depends on what he is logged in or not. In this case i just cleared up for case where user is logged in and he tries to add passport. Problem is that when i hit my route it calls it like twice which means log looks like this

[2015-03-22 11:24:45] local.INFO: I hitted connect method  
[2015-03-22 11:24:45] local.INFO: I created passport!  
[2015-03-22 11:24:45] local.INFO: i returned true  
[2015-03-22 11:24:45] local.INFO: I hitted connect method  
[2015-03-22 11:24:45] local.INFO: passport object exists  
[2015-03-22 11:24:45] local.INFO: and i returned true

Here is my controller and service class.

Controller http://laravel.io/bin/kW4oE Service http://laravel.io/bin/52kzy

I hope someone can help me point on my mistake. Thanks.

0 likes
7 replies
bashy's avatar

Have you checked exactly where it hits the connect method again?

Have you tried to see if it's the actual route by doing logging in here?

public function draugiem(DraugiemPassport $draugiemPassport) {}
Kemito's avatar

bashy, yes, i logged in route as well and it hits twice.

Kemito's avatar

Here is other thing. Just moved everything to controller

http://laravel.io/bin/xKYJQ

Problem is that first time i hit it is on 'how?' which means there are 2 requests and $_SERVER in log are the same. When i am on 'how?' dd() i delete record from database and hit route again and everything works fine. I go to home page, delete record and hit route and i get 'how?' again.

There is not a single middleware set before this.

bashy's avatar

How are you testing it? Browser?

Have you tried calling the address via cURL?

Kemito's avatar

@bashy Yes. via browser. i logged in this things. It gives the second request when i try to hit route from home page. When i break request somewhere (getting first dd('how?')) delete record and hit route again, everything works fine. Go to homepage, delete record, hit route - i got 'how?' and when i log entry points route is called twice. Even in this dd() functions actions like creating passport works but somehow dd does not stop them and second request go at the same time.

Kemito's avatar

This issue is on Chrome Version 41.0.2272.101 I tried on Firefox and everything works fine.

For google chrome i removed every extension i had.

Google chrome preserve log http://laravel.io/bin/zje6D

there is just one call so i think its issue with laravel for chrome?

Kemito's avatar

I took off https as well, moved everything to controller. Thing is it doesn`t matter. via xdebug it seems like it boots up application twice. Sometimes it does work, but it acts super weird. Hints?

Please or to participate in this conversation.