我需要一个快速帮助。 自动加载我的课程时,它会抛出一个错误:
Class 'Applicant\Respository\ApplicantInterface' does not exist
我尝试过查找一些有关自动加载的文章,包括fideloper example,但仍然没有运气。这是我的代码:
树结构
resultchecker
+app
+Applicant
+Helper
+Provider
+Repository
+Eloquent
-Applicant.php
-ApplicantInterface.php
ApplicantInterface.php
namespace Applicant\Repository;
interface ApplicantInterface {
public function all();
public function get();
public function lookup();
}
HomeController.php
use Applicant\Respository\ApplicantInterface;
class HomeController extends BaseController {
public function __construct(ApplicantInterface $applicantRepo)
{
$this->applicantRepo = $applicantRepo;
}
public function home()
{
return View::make('app.index');
}
composer.json
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"files" : [
"app/Applicant/Helper/functions.php"
],
"psr-0" : {
"Applicant" : "app/"
}
},
我在这里做错了什么?
答案 0 :(得分:0)
看起来您的ApplicantInterface.php
不在Repository
目录中,因此您必须将其移动以使您的结构如下所示:
resultchecker
-app
-Applicant
-Helper
-Provider
-Repository
-Eloquent
Applicant.php
ApplicantInterface.php
如果不起作用,请尝试运行php artisan dump-autoload
。
我还建议您从psr-0
切换到psr-4
自动加载:
"psr-4": {
"Applicant\\": "app/Applicant"
}
祝你好运!