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?
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
Try this in your top of the class(controller)
use View;
I bet your controller class has a namespace, yes? Try \View::make('home');
Or you can import it in the top of the file:
<?php
namespace App\Http\Controllers;
use View;
class HomeController extends Controller {
public function home() {
return View::make('home');
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With