【问题标题】:Laravel "auth controller not found" exceptionLaravel“找不到身份验证控制器”异常
【发布时间】:2015-12-09 06:46:09
【问题描述】:

我正在 LARAVEL4.2.* 中制作管理面板。我在“admin”文件夹中创建了控制器,也在“admin”文件夹中创建了一个视图。我的控制器代码是

namespace admin;

class AuthController extends \BaseController {

    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function index()
    {
        //
    }


    /**
     * Show the form for creating a new resource.
     *
     * @return Response
     */
    public function create()
    {
        //
    }


    /**
     * Store a newly created resource in storage.
     *
     * @return Response
     */
    public function store()
    {
        //
    }


    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function show($id)
    {
        //
    }


    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return Response
     */
    public function edit($id)
    {
        //
    }


    /**
     * Update the specified resource in storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function update($id)
    {
        //
    }


    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return Response
     */
    public function destroy($id)
    {
        //
    }


}

我的路线编码是:

Route::get('admin/login',   array('as' => 'admin.login',       'uses' => 'App\Controllers\Admin\AuthController@getLogin'));

我也尝试过 50 次以上的“composer update”和“composer dump-autoload”。我的网址是 localhost/laraveltest/public/admin/login。

【问题讨论】:

    标签: laravel-routing


    【解决方案1】:

    您将命名空间定义为admin,因此您也必须在路由中使用它:

     Route::get('admin/login', array('uses' => '\admin\AuthController@getLogin'));
    

    【讨论】:

    • 似乎你有点搞砸了你的命名空间。对于初学者,尝试从控制器和路由中删除所有命名空间并运行 $ composer dump-autoload。
    猜你喜欢
    • 2014-03-06
    • 2016-05-31
    • 1970-01-01
    • 2017-05-17
    • 2012-07-06
    • 1970-01-01
    • 2017-01-23
    • 2012-12-23
    • 1970-01-01
    相关资源
    最近更新 更多