Why is a function necessary in Route::get?

Posted 6 months ago by davestead

I'm watching Laracasts, Laravel from Scratch, and the narrator shows the call in routes/web.php, as:

Route::get('/', function () { return view('welcome'); });

What I'm not understanding is why a function was determined to be the best thing to be in the 2nd param, as opposed to just specifying a view string.

My PHPStorm editor can't find the get function, or the Route class for some reason when I hover over or Ctrl+click them.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.