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

vahidvs's avatar

best practice for generate laravel request validation in rest api app

i have a restful app with laravel 5.5 and i am using laravel request class for validating requests before use theme in my controllers. so now i have many request class because there is one class for each action. for example loginRequest.php for login action and RegisterRequest.php for register and .... I am wondering if it is ok to produce requests in this way! i have five request just for AuthController and much more requests for other controllers! I can't merge them because of individual rules belongs to each one. so what is the best practice to handle this volume of requests?

0 likes
1 reply
andonovn's avatar

@vahidvs I don't think this is actually a problem. Having lots of Request classes is okay. If you are repeating yourself in some of them, just extract the shared code in a parent abstract class.

1 like

Please or to participate in this conversation.