我是Laravel框架的新手,我遇到了路由问题。
文件夹结构:
app
controllers\
admin\ authcontroller.php
路线:
Route::get('admin/logout', array('as' =>'admin.logout', 'uses'=>'App\Controllers\Admin\AuthController@getLogout' ));
Route::get('admin/login', array('as' =>'admin.login' , 'uses'=>'App\Controllers\Admin\AuthController@getLogin' ));
Route::get('admin/login',array('as'=>'admin.login.post','uses'=>'App\Controllers\Admin\AuthController@postLogin'));
Route::group( array('prefix' =>'admin' ,'before'=>'auth.admin' ),function (){
Route::any('/','App\Controllers\Admin\PagesController@index');
Route::resource('articles','APP\Controllers\Admin\ArticlesController');
Route::resource('pages','App\Controllers\Admin\PagesController');
});
authcontroller.php
<?php
namespace App\Controllers\Admin
use Auth, BaseController, Form, Input, Redirect, Sentry, View;
class Authcontroller extends BaseController
{
public function getLogin(){
die('here');
return View::make('admin.auth.login');
}
public function postLogin(){
$credentials= array(
'email' =>Input::get('email') ,
'password'=>Input::get('password'),
);
try{
$user=Sentry::authenticate($credentials,FALSE);
if($user){
return Redirect::route('admin.pages.index');
}
}
catch (Exception $e){
return Redirect::route('admin.login')->withErrors(array('login' => $e->getMessage() ));
}
}
/*
logout function
*/
public function getLogout(){
Sentry::logout();
return Redirect::route('admin.login');
}
}
错误:
Class App \ Controllers \ Admin \ AuthController不存在
该错误出现的原因是什么
当我从CMD运行composer dump-autoload时 我没有在autoload_namespaces.php文件中找到加载的命名空间
答案 0 :(得分:0)
您输入错误。您的控制器名称是&#34; Authcontroller&#34;在你的路线中它是&#34; AuthController&#34;。或者你已经看到了吗?