【问题标题】:Laravel error Symfony \ Component \ HttpKernel \ Exception \ HttpExceptionLaravel报错Symfony\Component\HttpKernel\Exception\HttpException
【发布时间】:2015-03-14 04:25:39
【问题描述】:

我的应用程序在 Ubuntu 中运行良好,但在将其迁移到 Windows 机器(本地)后,显示以下错误

Symfony \ Component \ HttpKernel \ Exception \ HttpException

这是我的 routes.php 代码

/*
  |--------------------------------------------------------------------------
  | Application Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It's a breeze. Simply tell Laravel the URIs it should respond to
  | and give it the Closure to execute when that URI is requested.
  |
 */
Route::get('/', 'HomeController@index');
Route::any('/signup', 'HomeController@signup');
Route::any('/login', 'HomeController@login');
Route::get('/logout', 'HomeController@logout');

// Custom routes for admin section
Route::any('admin/login', 'AdminController@login');
Route::get('admin/logout', 'AdminController@logout');
Route::any('admin/permissions/get-role-permissions', 'PermissionsController@get_role_permissions');
Route::any('admin/permissions/configure', 'PermissionsController@configure');

// Grouped routes for admin section
Route::group(array('before' => 'adminauth', 'except' => array('/admin/login', '/admin/logout')), function() {
    Route::resource('/admin/roles', 'RolesController');
    Route::resource('/admin/permissions', 'PermissionsController');
    Route::resource('/admin', 'AdminController');

});

// Grouped routes for front end
Route::group(array('before' => 'auth'), function() {
    Route::resource('/dashboard', 'UserController@index');
    Route::resource('/posts', 'PostsController');
});

当我调用 /admin/roles 或 /admin/permissions/configure 时,我收到上述错误,但它仅适用于 /admin。

【问题讨论】:

  • Route::resource('/admin/roles', array('uses' => 'RolesController')); 试试这样。

标签: laravel error-handling routing


【解决方案1】:

您的路线和最后一个路线组有错误:

// Grouped routes for front end
Route::group(array('before'=>'auth'), function() {
    // You cannot use Route::resource and use a controller method,
    // you need to use an entire controller.
    //
    // Route::resource('/dashboard','UserController@index'); // !!
    Route::get('/dashboard','UserController@index'); // here was the error
    // ...
});

【讨论】:

    猜你喜欢
    • 2019-03-01
    • 2018-07-21
    • 2014-08-13
    • 2019-10-17
    • 2018-09-25
    • 2014-06-28
    • 2020-06-22
    • 2019-07-01
    • 2018-09-06
    相关资源
    最近更新 更多