Skip to content

[12.x] add toJson to Request #56093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

[12.x] add toJson to Request #56093

wants to merge 1 commit into from

Conversation

braxey
Copy link

@braxey braxey commented Jun 21, 2025

Make requests Jsonable to facilitate debugging.

Example: Want to easily see what's in a request at the beginning of a non-GET or XHR request:

public function controllerAction(Request $request)
{
   logger()->debug($request->toJson());
   ...
}

@henzeb
Copy link
Contributor

henzeb commented Jun 21, 2025

You can do logger()->debug('my request', $request->toArray()) instead.

@devajmeireles
Copy link
Contributor

You can do logger()->debug('my request', $request->toArray()) instead.

It makes sense, but there are dozens of other use cases for toJson beyond the log example.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants