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

dmag's avatar
Level 6

Make Form Request Class return json

I validate the incoming request to my webhook with form request class. It switches to "json mode" and returns json automatically if the request contains header "Accept: application/json". However the request is coming from external source and doesn't contain this header, but I want this form request validation class to always be in "json mode" for that webhook.

0 likes
4 replies
dmag's avatar
Level 6

@Snapey ok, I see, but do you know why when I add the following to my form request validation class, it doesn't make it to return json:

public function wantsJson(): bool
{
    return false;
}
Snapey's avatar

@dmag probably because Lary invented it, as he does quite often

dmag's avatar
Level 6

@Snapey this method is available in a trait of a parent class of a form request.

Please or to participate in this conversation.