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

beuzathor's avatar

Use Request validation without injection (directly in controller)

I try to use my request class validation directly in my controller without injection.

So i think i need to create a request instance and after use it for to proceed to validation.

My request validation class is PublieArticleRequest

And in my controller i do

 public function statutpublie(Centre $centre)
    {
     $centre9 = $centre->toArray();
        $request = new Request();
        $request->request->add($centre9);
     $request = app('App\Http\Requests\Backend\PublieArticleRequest');
     
     //my stuff if validation is OK
    }

The validation takes place but all the rules are announced as bad and they are all good in real.

I do not know if the method is the right one. I just want to run a validation using an already existing class. But in my case the user click on a button, it does not send the complete form. I am therefore with a method get that prevents me to use the injection.

0 likes
0 replies

Please or to participate in this conversation.