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 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示