Reputation: 387
I am accessing my "HomeController" with this route:
Route::get('home', 'Controllers\Main\HomeController@getHome');
and keep getting this error:
"Symfony \ Component \ Debug \ Exception \ FatalErrorException Class 'Controllers\Main\View' not found"
I have tried two ways to create the controller which are:
Method 1:
namespace Controllers\Main;
use BaseController;
class HomeController extends BaseController {
public function getHome()
{
return View::make('main.home');
}
}
Method 2:
namespace Controllers\Main;
use Illuminate\Routing\Controllers\Controller;
class HomeController extends Controller{
public function getHome()
{
return View::make('main.home');
}
}
I have used "dump-autoload" and these seem to be using the controller in both cases otherwise an exception would have been thrown. The error pops up on both methods so I'm not quite what I'm missing.
Upvotes: 0
Views: 255
Reputation: 387
Fixed this problem by changing my route to:
Route::get('home', 'HomeController@getHome');
and my Controller to:
class HomeController extends BaseController {
public function getHome()
{
return View::make('main.home');
}
}
Upvotes: 0
Reputation: 1814
Your issue is that View
sit in the "global" namespace while you're on Controllers\Main
namespace, as you would use BaseController;
, also add use View;
.
Upvotes: 2