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

7. < HTTP/1.1 200 OK
8. < Access-Control-Allow-Origin: *
9. < Content-Type: application/json
10. < Date: Sun, 16 Feb 2014 06:50:09 GMT
11. < Server: gunicorn/0.17.4
12. < Content-Length: 335
13. < Connection: keep-alive
14. <
15. * Connection #0 to host httpbin.org left intact