Php 类别';JWT&x27;找不到
我正在尝试使用JWT运行身份验证API 我目前正在使用SlimFrameworkV3和PHP7.4.1,并使用PDO连接到MySQL。 我用composer来要求firebasePhp 类别';JWT&x27;找不到,php,firebase,firebase-authentication,jwt,slim,Php,Firebase,Firebase Authentication,Jwt,Slim,我正在尝试使用JWT运行身份验证API 我目前正在使用SlimFrameworkV3和PHP7.4.1,并使用PDO连接到MySQL。 我用composer来要求firebase C:\Users\Desktop\php>composer require firebase/php-jwt 当使用postman运行API时,我收到一条错误消息,说“未找到类'JWT'”第172行 <h1>Slim Application Error</h1> <p>The
C:\Users\Desktop\php>composer require firebase/php-jwt
当使用postman运行API时,我收到一条错误消息,说“未找到类'JWT'”第172行
<h1>Slim Application Error</h1>
<p>The application could not run because of the following error:</p>
<h2>Details</h2>
<div><strong>Type:</strong> Error</div>
<div><strong>Message:</strong> Class 'JWT' not found</div>
<div><strong>File:</strong> C:\Users\Desktop\php\src\routes\user.php</div>
<div><strong>Line:</strong> 172</div>
myindex.php中的代码
require __DIR__.'/./vendor/autoload.php';
use \Firebase\JWT\JWT;
require __DIR__.'/./src/config/db.php';
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
require_once __DIR__.'/./src/routes/user.php';
这是我的autoload.php
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit23b54112a5e426a79a0f306cc05fddce::getLoader();
是的,当我添加
use \Firebase\JWT\JWT
在我的user.php文件中,而不是index.php
感谢@jumper85的回答。请不要发布代码截图或其他文本内容。而是发布实际文本,并使用Stack Overflow的格式化工具对其进行标记。感谢@FrankvanPuffelen的建议。以后每当我发布一个问题时,我都会记下。我认为最重要的部分缺失了,user.php中发生了什么?我的猜测是,你没有在那里使用\Firebase\JWT\JWT
?你必须在你调用它的文件中使用它。
use \Firebase\JWT\JWT