Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4: Class does not exist

I'm using Laravel v4.2 and getting the following error:

Class UserController does not exist

Here is my code:

user.php

class UserController extends BaseController {

    public function index(){
        return View::make('/')->with('title', 'Home | Public Review');
    }
}

routes.php

Route::get( '/', array(
    'as' => 'index',
    'uses' => 'UserController@index'
) );

How do I resolve this error?

like image 303
PandaUser Avatar asked Jul 09 '14 01:07

PandaUser


1 Answers

Typically, in Laravel 4, you'll find class UserController residing in app/controllers/UserController.php.

Laravel doesn't actually care, so long as the class in your routes.php can be auto-loaded. Consequently, always consider running php artisan dump-autoload after class name or class file name changes to ensure the autoloader is updated.

like image 55
bishop Avatar answered Oct 04 '22 22:10

bishop