Skip to content

Conversation

@cerbero90
Copy link
Contributor

Sometimes developers may need to inspect requests sent via the Laravel HTTP client. This PR aims to introduce the popular dump() and dd() helpers in the client so that this syntax is possible:

Http::dump()->get($url);
Http::dd()->post($url);

The helpers will dump both the instance of Illuminate\Http\Client\Request and the client options used to perform the request:

Illuminate\Http\Client\Request {#685 ▼
  #request: GuzzleHttp\Psr7\Request {#480 ▶}
  #data: []
}

array:10 [▼
  "http_errors" => false
  "laravel_data" => []
  "on_stats" => Closure($transferStats) {#504 ▶}
  "synchronous" => true
  "handler" => GuzzleHttp\HandlerStack {#724 ▶}
  "cookies" => GuzzleHttp\Cookie\CookieJar {#853 ▶}
  "allow_redirects" => array:5 [▶]
  "decode_content" => true
  "verify" => true
  "idn_conversion" => false
]

To keep the same behavior of the homonym methods in Collections, it is also possible to pass extra variables to dump:

Http::dump($var1, $var2)->get($url);
Http::dd($var3)->post($url);

@taylorotwell taylorotwell merged commit b1d76be into laravel:8.x Mar 5, 2021
This was referenced Mar 10, 2021
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.

2 participants