Tuesday, March 7, 2017

Laravel 5 sub domain routing - Controller not found issue

I am trying my hand at creating a sub domain route for a project I am working on and I am able to get the sub domain working. However, the only time it works is if I return some copy directly from the routes.php. When I try to access a controller, it tells me that it's not found, when it's clearly there.

This code:

Route::group(['domain' => 'demo.tk.dev'], function(){
Route::get('/', 'DemoController@demoLanding');
});

Returns me this error:

ReflectionException in Route.php line 280:
Class app\Http\Controllers\DemoController does not exist

But if I do something like this:

Route::group(['domain' => 'demo.tk.dev'], function(){
Route::get('/', function() {
    return 'Success';
});
});

Then that works.

I am not seeing anything in the documentation about making any other changes for the Controllers to work with the sub domain. Am I missing something? Any help would be greatly appreciated.



via lpangm03

Advertisement