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 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败