当我尝试在index.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]
composer.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',
);
index.php
require_once __DIR__ . '/vendor/autoload.php';
答案 0 :(得分:0)
看起来您像一个水平。试试这个:
require_once dirname(__DIR__) . '/vendor/autoload.php';