namespace APP\Controllers\GP;
class LoginController extends BaseController
{
/**
* 返回登录首页
* 如果用户已经保存密码,则直接登录后台,否则用户显示登录界面
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
*/
public function anyIndex()
{
if (\Auth::check())
return \Redirect::to(U('GP/Login/index'));
return \View::make('GP.Login.index');
}
}
/*GP模块路由*/
Route::group(array('prefix' => 'GP','namespace' => 'APP\Controllers\GP'), function() {
Route::controller('GP', 'LoginController', array(
'anyIndex' => 'GP.Login.index'
));
});
运行报错:
ReflectionException(-1)
Class APP\Controllers\GP LoginController does not exist
解决办法:
在PHPstorm Terminal控制台输入“composer dump-autoload”
因为laravel是用composer来加载类,不是命令创建的类要更新autoload。