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

tristanisginger's avatar

Route syntax/semantics opinion

Hi

I'm new to Laravel and am trying to make sure I start with good habits.

When writing routes I'd like to know which method people prefer and if there are what the pros and cons of each way. (Is there another way?)

Route::get('/home', 'Backend\HomeController@index')->name('home');
Route::get('/home', [
    'as' => 'home', 
    'uses' => 'Backend\HomeController@index'
]);

Thanks

0 likes
1 reply
thomaskim's avatar

Personally, I prefer the first option. I think it looks cleaner and is easier to understand.

Ultimately though, it doesn't matter. Just go with the option that you like.

1 like

Please or to participate in this conversation.