manshu manshu - 4 years ago 117
PHP Question

how to setup routes, controller, and views the proper way?

I just started playing around with laravel. First of all, this is the best framework i've came across. Now here is my issue. I am trying to point from routes -> controller -> view

//This is my Controller file

public function index()
return View::make('pages', array('name' => 'Taylor'));

// This is my Routes File
Route::get('/', 'pagesController@index');

View file => pages.blade.php

This is the error i'm getting.

FatalErrorException in pagesController.php line 19:
Class 'App\Http\Controllers\View' not found

Answer Source

From the error it seems that the problem is that the View class is not found in the current namespace.

Try this way:

//use the View class from the global namespace
return \View::make('pages', array('name' => 'Taylor'));

or import the View class at the beginning of the controller's script:

use View;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download