debug

摘要

设置成 true 或设置成一个 fopen() 返回的流来启用调试输出发送请求的处理器, 比如,当使用cURL传输请求,cURL的 CURLOPT_VERBOSE 的冗长将会发出, 当使用PHP流,流处理的提示将会发生。 如果设置为true,输出到PHP标准输出文件,如果提供了PHP流,将会输出到流。

类型

  • bool
  • fopen() resource

默认值

None

常量

GuzzleHttp\RequestOptions::DEBUG

  1. $client->request('GET', '/get', ['debug' => true]);

执行上面的例子将会输出类似下面的结果:

  1. * About to connect() to httpbin.org port 80 (#0)
  2. * Trying 107.21.213.98... * Connected to httpbin.org (107.21.213.98) port 80 (#0)
  3. > GET /get HTTP/1.1
  4. Host: httpbin.org
  5. User-Agent: Guzzle/4.0 curl/7.21.4 PHP/5.5.7
  6. < HTTP/1.1 200 OK
  7. < Access-Control-Allow-Origin: *
  8. < Content-Type: application/json
  9. < Date: Sun, 16 Feb 2014 06:50:09 GMT
  10. < Server: gunicorn/0.17.4
  11. < Content-Length: 335
  12. < Connection: keep-alive
  13. <
  14. * Connection #0 to host httpbin.org left intact