Your namespace should be:
namespace Subfolder
And in routes:
Route::controller('/Main', 'Subfolder\MainController');
Ok that looks fine, but Laravel always show me this error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
Controller method not found.
My controller now looks like this:
<?php
namespace Subfolder;
class MainController extends \BaseController {
public function index()
{
dd('Main works');
}
public function getIndex()
{
dd('Main works');
}
But still an error message.
Wow!!! That is nice.
I found in the log file that Laravel tries to call the "HomeController" instead of the "MainController". So I changed the order in the routes from this:
Route::controller('/', 'HomeController');
Route::controller('/Subfolder', 'Subfolder\MainController');
...to this new order:
Route::controller('/Subfolder', 'Subfolder\MainController');
Route::controller('/', 'HomeController');
And now the MainController is working.
Why is that so???
I think you need to remove the "/" from "/subfolder" so
Route::controller('Subfolder', 'Subfolder\MainController');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community