标题说明了自己.所以这是我的项目结构:
|src
|Database
|Core
|MySQL.php
|Support
start.php
|vendor
composer.json
index.php
MySQL.php文件:
namespace Database\Core;
//Some methods here
index.php和start.php文件:
//start.php file
require __DIR__ . '/../vendor/autoload.php';
?>
//index.php file
use Database\Core;
require __DIR__ . '/src/start.php';
$mysql = new MySQL(); // Gets exception Class 'MySQL' cannot found etc.
?>
最后我的composer.json自动加载部分:
"autoload": {
"psr-4": "Database\\": "src/" // Also tried "src/Database" too
}
问题出在哪儿?我真的厌倦了试图应对这种情况.请帮帮我们!谢谢.