当我访问domain.com/article
时,我收到错误:
Class Blog\Controllers\Article does not exist
造成这种情况或我做错了什么?
app/controllers/Article.php:
namespace Blog\Controllers;
use View;
use BaseController;
class Article extends \BaseController
{
public function showIndex()
{
return 'index view';
}
}
app/routes.php:
Route::controller('article', 'Blog\Controllers\Article');
答案 0 :(得分:2)
您的namespace
和directory
不匹配,请根据您的namespace
psr-0
// Class Path : "app/controllers/blog/controllers/Article.php"
namespace Blog\Controllers;
use View;
use BaseController;
class Article extends \BaseController
{
public function getIndex()
{
return 'index view';
}
}
另外,请注意getIndex()
而不是showIndex()
,read more on documentation。