Php 致命错误:未捕获错误:类';请求';使用请求时未找到

Php 致命错误:未捕获错误:类';请求';使用请求时未找到,php,httprequest,Php,Httprequest,当我使用 在我的smarty的test.php文件中: require_once($_SERVER['DOCUMENT_ROOT'] . '/libs/src/Requests/library/Requests.php'); $headers = array('Accept'=>'application/json', 'Authorization' => 'Bearer AwSBtNOd3Fw4NkDUDdoZqqwFOCKDxi'); $request = Requests::g

当我使用

在我的smarty的
test.php
文件中:

require_once($_SERVER['DOCUMENT_ROOT'] . '/libs/src/Requests/library/Requests.php');

$headers = array('Accept'=>'application/json', 'Authorization' => 'Bearer AwSBtNOd3Fw4NkDUDdoZqqwFOCKDxi');
$request = Requests::get('http://localhost:8000/amodel/list/', $headers, []);

$res = array(
    'status'=>var_dump($request->status_code),
    'data'=>var_dump($request->body)
);

$smarty->assign('res', $res);

$smarty->display('test.tpl');
但是,当我访问
test.php
时,会出现致命错误:

致命错误:未捕获错误:在/Users/james/Desktop/TestPHP/smarty-test02/libs/src/Requests/library/Requests.php:568堆栈跟踪:#0/Users/james/Desktop/TestPHP/smarty-test02/libs/src/Requests/library/Requests.php(363):Requests::set_默认值(“…”,数组,NULL,'GET',数组)php(231):Requests::Requests(“…”,Array,NULL,'GET',Array)#2/Users/james/Desktop/TestPHP/smarty-test02/test.php(36):Requests::GET(“…”,Array,Array)#3{main}在第568行的/Users/james/Desktop/TestPHP/smarty-test02/libs/src/Requests/library/Requests.php中抛出


编辑-1


我一直在关注GitHub文档,我不确定引发此问题的原因是什么。

与大多数现代PHP库一样,该库依赖于自动加载。如果你使用的是composer,你可以免费获得它。如果是手动安装,则需要注意自动加载器。如文件所述:

并将其包含在脚本中:

require_once '/path/to/Requests/library/Requests.php';
您可能还需要注册自动加载器:

Requests::register_autoloader();