ServerSideSkittles
ServerSideSkittles

Reputation: 2973

FatalErrorException in HomeController.php line 8: Class 'App\Http\Controllers\Controller' not found

New to laravel and I am trying to setup the user auth. I am using laravel 5.1 so I had to add

"bestmomo/scafold": "dev-master"

to composer.json

also in my composer.json

  "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "TestApp\\": "app/"
        }
    },

This lets me bring up the register and login pages at /auth/login , /auth/register.

When I complete register it throws back

FatalErrorException in HomeController.php line 8:
Class 'App\Http\Controllers\Controller' not found

in HomeController.php line 8

I have also named my app using

php artisan app:name TestApp

The user details are stored correctly in the db, then when I navigate anywhere on the site it throws the error because im assuming its recognised the session.

I haven't strayed far from guides and this is a simple setup, not sure why its not working.

I am not sure where the "HomeController" is but the default controller in my dir is Controller.php and contains

namespace TestApp\Http\Controllers;

use TestApp\Http\Controllers\Controller;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

abstract class Controller extends BaseController
{
    use DispatchesJobs, ValidatesRequests;
}

The Dir structure is as follows

Dir structure

Upvotes: 1

Views: 10109

Answers (1)

Nehal Hasnayeen
Nehal Hasnayeen

Reputation: 1223

When you change your app name your application namespace is also changed , so your application namespace is right now TestApp. so in your HomeController file change your use statement , its still using previous namespace , you should use

use TestApp\Http\Controllers\Controller;

Upvotes: 3

Related Questions