当我尝试要求在我的索引.php文件中自动加载时,我收到此错误警告:require_once(C:\xampp\htdocs\gacho\public/vendor/autoload.php(:无法打开流。现在我知道供应商文件夹的路径不正确,但我找不到正确的路径。我也在使用.htaccess文件,我认为这必须与问题有关。这是我的代码结构和代码:
代码结构:
gacho
|- app
|- controller
|- core
|- model
|- view
|-public
|- .htaccess
|- index.php
|-vendor
|- composer
|- autoload_classmap.php
|- autoload.php
|-composer.json
.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [QSA,L]
作曲家.json
{
"autoload": {
"classmap":[
"app"
]
}
}
autoload_classmap
return array(
'App\Controller\HomeController' => $baseDir .
'/app/controller/HomeController.php',
'App\Core\Application' => $baseDir . '/app/core/Application.php',
'App\Core\Controller' => $baseDir . '/app/core/Controller.php',
'App\Core\Database' => $baseDir . '/app/core/Database.php',
'App\Core\View' => $baseDir . '/app/core/View.php',
'App\Model\User' => $baseDir . '/app/model/User.php',
);
索引.php
require_once __DIR__ . '/vendor/autoload.php';
看起来你差了一个级别。 试试这个:
require_once dirname(__DIR__) . '/vendor/autoload.php';