simple Laravel View::make() not working

Ryan DuShane picture Ryan DuShane · Mar 6, 2015 · Viewed 19.5k times · Source

So I'm learning some basic Laravel stuff as I am new to PHP. I am following a basic tutorial that is having me print stuff to a file named home.blade.php.

The way I am calling it now is as follows.

Here is my routes.php

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

Here is my HomeController.php

class HomeController extends Controller {

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

}

Here is home.blade.php

{{'Hello.'}}

Before you ask, yes my home.blade.php is inside of my Views folder.

The error print out is as follows

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()

Here's the odd part. If I change my routes.php to simply contain

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

it functions fine.

Does anyone have an idea of what I could do?

Answer

mininoz picture mininoz · Mar 6, 2015

New syntax for Laravel 5

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

For more information you can read it from here http://laravel.com/docs/5.0/views