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
Try this php artisan dump-autoload” and “composer dump-autoload”
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.
Thanks a lot guys. My mistake was in prefix, i thought it tells to load controller from site directory....
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community