问题:
我具有以下文件结构
-api (contains index.php)
--src
---vendor
----auth (contains auth.php)
----bin
----composer
----nesbot
----rbdwllr
----sympfony
这是我的composer.json
{
"autoload": {
"psr-4": {
"AuthSpace\\": "/auth",
"Tests\\": "/rbdwllr/reallysimplejwt/tests",
"Symfony\\Polyfill\\Mbstring\\": "/symfony/polyfill-mbstring",
"Symfony\\Component\\Translation\\": "/symfony/translation",
"ReallySimpleJWT\\Helper\\": "/rbdwllr/reallysimplejwt/src/Helper",
"ReallySimpleJWT\\Exception\\": "/rbdwllr/reallysimplejwt/src/Exception",
"ReallySimpleJWT\\": "/rbdwllr/reallysimplejwt/src",
"": "/nesbot/carbon/src"
}
}
}
index.php
require __DIR__ . '/src/vendor/autoload.php';
$argument1 = $_GET['argument1'];
$tokenCode = $_GET['tokenCode'];
include 'config/database.php';
include 'objects/program1.php';
include 'auth.php';
use ReallySimpleJWT\Token;
use Carbon\Carbon;
$secret = "somesecret";
if (($_SERVER['REQUEST_METHOD']) == "GET") {
if ($_GET['url'] == "bankquery") {
if($tokenCode===NULL){
echo "no correct token provided";
print($results);
} else {
$results = Token::validate($tokenCode, $secret);
if ($results = 1){
$var = new AuthClass();
$var = AuthClass::checkTime($tokenCode);
} else {
echo "no correct token provided";
}
}
} else {
echo "some GET other query";
}
?>
auth.php
<?php namespace AuthSpace;
use ReallySimpleJWT\Token;
use Carbon\Carbon;
class AuthClass{
public static function checkTime($tokenCode){
// getting payload from token code by accessing the composer dependency method in a class Token
$received = Token::getPayload($tokenCode);
return $received;
}}
?>
我已经使用composer dump-autoload
生成了自动加载功能,并检查了prs4链接-它们似乎都显示了正确的目录和名称空间链接。
但是,尽管如此,运行index.php文件后,我仍然收到以下错误,但不知道为什么。
PHP致命错误:未捕获的错误:没有类'AuthSpace \ AuthClass' 找到