我正在学习 Composer 的工作方式(开发新手 ^^)但我正在努力修复我的自动加载...这是我的 composer.json : "autoload": { "psr-4": { "OCFram\\": "/../lib/", "App\\": "/../", "Model\\": "/../lib/vendors/", "Entity\\": "/../lib/vendors/", "FormBuilder\\": "/../lib/vendors/", "Slug\\": "/../lib/vendors/" } },例如:致命错误:未捕获错误:找不到类“App\Frontend\FrontendApplication”好吧,FrontendApplication 路径(来自 composer.json):**../App/Frontend/FrontendApplication.php这是带有命名空间的 FrontendApplication.php : <?php namespace App\Frontend; use \OCFram\Application; class FrontendApplication extends Application { public function __construct() { parent::__construct(); $this->name = 'Frontend'; } public function run() { $controller = $this->getController(); $controller->execute(); $this->httpResponse->setPage($controller->page()); $this->httpResponse->send(); } }另外,我注意到了 vendor/composer 上的这个文件 (autoload_psr4.php): <?php// autoload_psr4.php @generated by Composer $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( 'Slug\\' => array('/lib/vendors'), 'OCFram\\' => array('/lib'), 'Model\\' => array('/lib/vendors'), 'FormBuilder\\' => array('/lib/vendors'), 'Entity\\' => array('/lib/vendors'), 'App\\' => array('/'), );希望得到一些帮助:)
1 回答
慕田峪7331174
TA贡献1828条经验 获得超13个赞
根据你的说法:
好吧,FrontendApplication 路径(来自 composer.json):**
../App/Frontend/FrontendApplication.php
您的文件夹结构似乎是:
/App
/<some-dir>/composer.json
看起来你只是App在路径中错过了,你不需要前导或尾随斜线。
"autoload": {
"psr-4": {
"OCFram\\": "../lib",
"App\\": "../App",
"Model\\": "../lib/vendors",
"Entity\\": "../lib/vendors",
"FormBuilder\\": "../lib/vendors",
"Slug\\": "../lib/vendors"
}
},
- 1 回答
- 0 关注
- 162 浏览
添加回答
举报
0/150
提交
取消