Laravel: returning a view from a controller
I am trying to find out how to use Laravel 5, but I am facing a problem. So far I've created the following code:
under app/HTTP/routes.php
:
<?php
Route::get('/', 'MyController@home');
Created my own MyController.php
file in app\Http\Controllers
and added the following code to the controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller as BaseController;
class MyController extends BaseController
{
public function home()
{
$name = "John Doe";
return View::make("index")->with("name", $name);
}
}
When I run the application, I get the error:
FatalErrorException in MyController.php line 12:
Class 'App\Http\Controllers\View' not found
What am I doing wrong?
+3
source to share