Support the ongoing development of Laravel.io →
Requests

I'm a bit confusing about how to work with controllers which is in subfolders of controller dir. For example i have file like this /home/web/www/app/controllers/Site/UserController.php which looks like this:

<?php
class UserController extends BaseController {

	public function index()
	{
		return View::make('hello');
	}

}

My route.php looks like this:

Route::group(array('prefix' => 'site'), function() {
	Route::get('/', 'UserController@index');
});

When i try to load i get this exception Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

Last updated 2 years ago.
0

Try this php artisan dump-autoload” and “composer dump-autoload”

Last updated 2 years ago.
0

Hi trololosha4real,

Try adding in your app/start/global.php the following line:

ClassLoader::addDirectories(array(

    app_path().'/commands',
    app_path().'/controllers',
    app_path().'/controllers/Site',
    ....
));

Or try using composer.json file and adding the same folder to autoload section:

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/controllers/Site",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php"
    ]
},

Then you need to use php artisan dump-autoload CLI command.

Try and comment us.

Hope it helps you.

Last updated 2 years ago.
0

Thanks a lot guys. My mistake was in prefix, i thought it tells to load controller from site directory....

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.

© 2025 Laravel.io - All rights reserved.