1

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

2
  • 2
    can you please update your question with directory structure of controllers folder and code of HomeController, use statements to be specific?` Commented Jul 12, 2015 at 3:45
  • 1
    as you changed your app name your application namespace is now TestApp, so you should replace App to TestApp every where it is referenced, for this error i think in your HomeController change your use App\Http\Controllers\Controller to use TestApp\Http\Controllers\Controller Commented Jul 12, 2015 at 6:55

1 Answer 1

3

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;
Sign up to request clarification or add additional context in comments.

2 Comments

Seems my namespace is ok, I have that in the Controller.php and AuthController.php.
This was the issue. I was looking for the error in the controllers directory but didn't realise there was one in vendors folder. Thankyou very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.