simple Laravel View::make()不起作用


simple Laravel View::make() not working

因此,作为PHP新手,我正在学习一些基本的Laravel内容。我正在遵循一个基本教程,让我将内容打印到一个名为home.blade.php的文件中。

我现在这样称呼它。

这是我的routes.php

Route::get('/', array(
    'as' => 'home',
    'uses' => 'HomeController@home'
));

这是我的HomeController.php

class HomeController extends Controller {
    public function home() {
        return View::make('home');
    }
}

这是home.blade.php

{{'Hello.'}}

在你问之前,是的,我的home.blade.php在我的Views文件夹中。

错误打印如下

FatalErrorException in HomeController.php line 6:
Class 'App'Http'Controllers'View' not found
in HomeController.php line 6
at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Class 'App'Http'Controllers'View' not found', 'file' => '/Users/ryandushane/Google Drive/Web_WorkSpace/theNeonSurf/app/Http/Controllers/HomeController.php', 'line' => '6')) in compiled.php line 1738
at HandleExceptions->handleShutdown()

这是奇怪的部分。如果我将routes.php更改为仅包含

Route::get('/', function()
{
    return View::make('home');
});

它的功能很好。

有人知道我能做什么吗?

Laravel 5的新语法

public function home() {
    return view('home');
}

有关更多信息,您可以从这里阅读http://laravel.com/docs/5.0/views

在顶级(控制器)中尝试

use View;

我打赌你的控制器类有一个命名空间,是吗?试试'View::make('home');或者你可以在文件的顶部导入它:

<?php
namespace App'Http'Controllers;
use View;
class HomeController extends Controller {
    public function home() {
        return View::make('home');
    }
}