As i remember, Laravel build controller first. So anything in the constructor is call before the routes/controllers middlewares.
Edit :
https://laravel-news.com/controller-construct-session-changes-in-laravel-5-3
Hello,
I'm facing a weird problem on execution order inside a controller's constructor.
Consider this Controller code:
public function __construct()
{
$this->middleware(MyStupidMiddleware::class);
echo "2";
}
And MyStupidMiddleware code:
public function handle($request, Closure $next)
{
echo "1";
return $next($request);
}
When I execute the request, I get 2 and 1!
WHY?
Please or to participate in this conversation.