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

Moe's avatar
Level 6

routes with query strings

When I add this route to web.php

route::get('invitation?token=test', function () { return 'test'; });

I get a 404 when visiting the page .../invitation?token=test

What am i doing wrong?

0 likes
3 replies
tykus's avatar
tykus
Best Answer
Level 104

You do not define the expected querry string in the Route definition. You get the query params from the Request object:

Route::get('invitation', function () {
    dump(request()->all()); // ['token' => 'test']
});
2 likes
Moe's avatar
Level 6

Ok, didn't knew it wasn't possible.

tykus's avatar

No worries. Please mark the Best Reply above to help others who have the same question in the future

Please or to participate in this conversation.