4中找不到控制器路由

4中找不到控制器路由

本文介绍了在Laravel 4中找不到控制器路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从L3迁移到L4.注册默认L4安装随附的HomeController控制器时,尝试转到页面www.domain.com/home会给我一个ResourceNotFound异常.我做了composer dumpautoload,但这没有帮助.

I am in the process of migrating from L3 to L4. When registering the HomeController controller that came with the default L4 installation, trying to go to the page www.domain.com/home gives me a ResourceNotFound exception. I did a composer dumpautoload but that did not help.

我错过了一个额外的步骤吗?

Did I miss out an additional step?

routes.php

Route::controller('home', 'HomeController');

controllers/HomeController.php

<?php

class HomeController extends BaseController {

    public function showWelcome()
    {
        return View::make('hello');
    }

}

错误堆栈跟踪

NotFoundHttpException:
in /var/www/l4/vendor/laravel/framework/src/Illuminate/Routing/Router.php line 1338
at Router->handleRoutingException(object(ResourceNotFoundException)) in /var/www/l4/vendor/laravel/framework/src/Illuminate/Routing/Router.php line 992
at Router->findRoute(object(Request)) in /var/www/l4/vendor/laravel/framework/src/Illuminate/Routing/Router.php line 956
at Router->dispatch(object(Request)) in /var/www/l4/vendor/laravel/framework/src/Illuminate/Foundation/Application.php line 463
at Application->dispatch(object(Request)) in /var/www/l4/vendor/laravel/framework/src/Illuminate/Foundation/Application.php line 448
at Application->run() in /var/www/l4/public/index.php line 51

推荐答案

根据文档:

所以:

class UserController extends BaseController {

    public function getIndex()
    {
        // Would response to /user and /user/index
    }
}

因此,在您的情况下,只需将showWelcome()重命名为getWelcome()就足够了.

So, in your case simply renaming showWelcome() to getWelcome() should suffice.

这篇关于在Laravel 4中找不到控制器路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 03:37