未定义的偏移量:json 响应 var_dump() 期间 Guzzle 中为 0

Undefined offset: 0 in Guzzle during var_dump() on json response

我正在关注 Guzzle 的文档并卡在 json 响应上。这是我的代码

require 'vendor/autoload.php';
use GuzzleHttp\Client;

$client = new Client();
$response = $client->get('http://httpbin.org/get');
$json = $response->json();
var_dump($json[0]['origin']);

当我 运行 这个文件时我得到错误

Notice: Undefined offset: 0 in C:\xampp\htdocs\guzzle\config.php on line 8
NULL 

为什么我得到未定义的偏移量?

可以找到可以提供相同问题和答案的以前的堆栈溢出问题here and here

来自Guzzle Docs

Guzzle uses the json_decode() method of PHP and uses arrays rather than stdClass objects for objects.

PHP 正在尝试访问 $json 数组的键 0。它没有找到一个值,而是遇到了 [0] 的未定义偏移并抛出错误。