我正在学习 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('/'),
);
希望得到一些帮助:)
慕田峪7331174