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

TobiasS's avatar
Level 10

Multiple routes in web.php or query string?

Hi!

I have 15-20 pdf:s that the user can choose to print.

What would be the best way to show the pdf the user chose?

At the moment I use a query string with the name of the function inside the controller and route to pdfController@index.

Is this the best way? (I have the drawback that the controller is really long and with lots of functions)

Or would it be better to have multiple Controllers whit just one function? And then the drawback of having multiple lines in web.php routing to all the controllers?

Thanks in advance!

0 likes
3 replies
bobbybouwmann's avatar
Level 88

I would personally try to keep my controllers small and have multiple routes. The routes give a good overview of all the functionality in your application. If you put a lot of magic in the controller this becomes unclear. Also, you always need to read the controller code to understand how it works.

Both options are fine in the end, but that is up to you ;)

TobiasS's avatar
Level 10

Thx! Refactored to small controllers, sharing code using traits

Please or to participate in this conversation.