Laravel一直告诉我,我的课程还没有找到,而且我很确定我已经用尽了任何解决方案。
路线:
Route::get('/custom-reports/timezone', array( 'uses' => 'Controllers\Reports\TimezoneController@generate'));
目录:
app/controllers/Reports/TimezoneController.php
TimzoneController.php
<?php
namespace Controllers\Reports;
use Controllers\BaseController;
class TimezoneController extends BaseController
{
public function generate() {}
}
Composer.json:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/libraries",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php",
"app/libraries/Illuminate/Cookie/Guard.php"
],
"files": [
"app/helpers.php"
]
},
错误:
ReflectionException -1
Class Controllers\Reports\TimezoneController does not exist
我已经完成了php composer dump-autoload
答案 0 :(得分:1)
classmap
不支持命名空间(据我所知),因此您需要设置PSR-4自动加载器。
将您的composer.json
更改为此并运行composer dump-autoload
。它应该在那之后工作。
"autoload": {
"classmap": [
...
],
"files": [
...
],
"psr-4": {
"Controllers\\": "app/controllers"
}
},