doutongya8378 2015-04-06 09:28
浏览 91
已采纳

Laravel 5控制器路由不起作用

I am familiar with Laravel 4 routes, but I am experiencing some problem with Laravel 5.

I code route.php as:

     Route::get('/','HomeController@index');

and my HomeController.php is the following:

<?php 
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;

class HomeController extends Controller {

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

The output page displays as:

 Whoops,looks like something went wrong.

The Route annotation file seems to be perfect.

The same case occurs for folder routing too!!

Please help me out.

  • 写回答

3条回答 默认 最新

  • donglin6659 2015-04-07 08:11
    关注

    First of all you should follow the instructions from James Njuguna in a comment to your question. Withoug debugging we can only guess whats going wrong.

    In your case, most likely your error is, that the line

    return View::make('index');
    

    is causing an exception, because class App\Http\Controllers\View is not found. In this file a namespace is used, so you have to reference the root namespace like:

    return \View::make('index');
    

    OR you use a helper function

    return view('index');
    

    This function is documentated at http://laravel.com/docs/5.0/helpers#miscellaneous

    If that's still failing... maybe you don't have an index.php or index.blade.php in your resources/views folder.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?