Support the ongoing development of Laravel.io →
Installation Configuration Requests
Last updated 2 years ago.
0

Your namespace should be:

namespace Subfolder

And in routes:

Route::controller('/Main', 'Subfolder\MainController');
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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???

Last updated 2 years ago.
0

I think you need to remove the "/" from "/subfolder" so

Route::controller('Subfolder', 'Subfolder\MainController');
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

TKlement tklement Joined 23 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.